Advertisement
Guest User

Untitled

a guest
May 29th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <queue>
  5. #include <stack>
  6. #include <map>
  7. #include <algorithm>
  8. #include <numeric>
  9. #include <functional>
  10. #include <set>
  11. #include <sstream>
  12. #include <cstdio>
  13. #include <cstdlib>
  14. #include <cstring>
  15. #include <cmath>
  16. #include <cctype>
  17. #include <climits>
  18. #include <fstream>
  19. #include <time.h>
  20.  
  21. #define FOR(i,a,b) for(int i=(a);i<(b);++i)
  22. #define FORE(i,a,b) for(int i=(a);i<=(b);++i)
  23. #define REP(i,n) FOR(i,0,n)
  24. #define REPE(i,n) FORE(i,0,n)
  25. #define FOE(i,a) for(auto i : a)
  26. #define ALL(c) (c).begin(), (c).end()
  27. #define DUMP(x) cerr << #x << " = " << (x) << endl;
  28. #define SUM(x) std::accumulate(ALL(x), 0L)
  29.  
  30. using namespace std;
  31.  
  32.  
  33. struct FoxAndWord {
  34. vector<string> words;
  35. int howManyPairs(vector<string> _words) {
  36. words = _words;
  37. int ans = 0;
  38. REP(i, words.size()) {
  39. FOR(j, i + 1, words.size()) {
  40. if (words[i].size() != words[j].size()) { continue; }
  41. string tt = words[j] + words[j];
  42.  
  43. if (tt.find(words[i]) != string::npos) {
  44. ans++;
  45. }
  46. }
  47. }
  48. return ans;
  49. }
  50. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement