fork download
  1. #include <vector>
  2. #include <list>
  3. #include <map>
  4. #include <set>
  5. #include <deque>
  6. #include <queue>
  7. #include <stack>
  8. #include <bitset>
  9. #include <algorithm>
  10. #include <functional>
  11. #include <numeric>
  12. #include <utility>
  13. #include <sstream>
  14. #include <iostream>
  15. #include <iomanip>
  16. #include <cstdio>
  17. #include <cmath>
  18. #include <cstdlib>
  19. #include <cctype>
  20. #include <string>
  21. #include <cstring>
  22. #include <cstdio>
  23. #include <cmath>
  24. #include <cstdlib>
  25. #include <ctime>
  26. using namespace std;
  27.  
  28. #define FOI(i, A, B) for(i=A; i<=B; i++)
  29. #define FOD(i, A, B) for(i=A; i>=B; i--)
  30.  
  31. string rem(string S){
  32. sort(S.begin(), S.end());
  33. int L = S.length() - 1, i;
  34. string R = "";
  35. FOI(i, 0, L)
  36. if (!isspace(S[i]))
  37. R += S[i];
  38. return R;
  39. }
  40.  
  41. int main(){
  42. //freopen("testI.txt", "r", stdin);
  43. //freopen("testO.txt", "w", stdout);
  44. int T;
  45. cin >> T;
  46. string str;
  47. getline(cin, str); getline(cin, str);
  48. while (T--){
  49. vector< string > V;
  50. map<string, string> Map;
  51. while (getline(cin, str)){
  52. if (str == "")
  53. break;
  54. V.push_back(str);
  55. Map[str] = rem(str);
  56. }
  57. sort(V.begin(), V.end());
  58. int SZ = V.size() - 1;
  59. int i, j;
  60. FOI(i, 0, SZ)
  61. FOI(j, i+1, SZ)
  62. if (Map[V[i]] == Map[V[j]])
  63. cout << V[i] << " = " << V[j] << endl;
  64. if (T)
  65. cout << endl;
  66. }
  67. return 0;
  68. }
  69.  
Success #stdin #stdout 0s 15248KB
stdin
6

carthorse.!@#$%^&*
horse
horse cart*&^%$#@!.
orchestra
i do not know u
ok i now donut

zaaaahari is here
si hari ere h aaaaz
i like tunes
tunes i like

carthorse
horse
horse cart
i do not know u
ok i now donut
orchestra

carthorse
horse
horse cart
i do not know u
ok i now donut
orchestra

abc
def

cba
abc
stdout
carthorse.!@#$%^&* = horse cart*&^%$#@!.
i do not know u = ok i now donut

i like tunes = tunes i like
si hari ere h aaaaz = zaaaahari is here

carthorse = horse cart
carthorse = orchestra
horse cart = orchestra
i do not know u = ok i now donut

carthorse = horse cart
carthorse = orchestra
horse cart = orchestra
i do not know u = ok i now donut


abc = cba