fork(2) download
  1. #include <cstdio>
  2. #include <string>
  3. #include <set>
  4. #include <sstream>
  5. #include <iostream>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11. int t, z;
  12. scanf("%d", &t);
  13.  
  14. while (t--) {
  15. string buf, str;
  16. getline(cin, str);
  17. stringstream ss(str);
  18. int cnt = 0;
  19.  
  20. set<string> tokens;
  21.  
  22. while (ss >> buf) {
  23. tokens.insert(buf);
  24. }
  25.  
  26. for (set<string>::iterator it = tokens.begin(); it != tokens.end(); ++it) {
  27. cnt++;
  28. }
  29.  
  30. printf("%d\n", cnt);
  31. }
  32.  
  33. return 0;
  34. }
Success #stdin #stdout 0s 3480KB
stdin
4
now do it now
now      do it now
I am  good boy
am am
stdout
0
3
3
4