fork(1) download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <cstdio>
  4. #include <cstring>
  5. using namespace std;
  6. int main(void)
  7. {
  8. int x, y, z, p, q, r, m;
  9. char a[50], b[50];
  10. scanf ("%d", &x);
  11. for (x; x > 0; --x)
  12. {
  13. scanf ("%s", &a);
  14. scanf ("%s", &b);
  15. m = 0;
  16. if (strlen(a) != strlen(b))
  17. printf ("NO\n");
  18. else
  19. sort (a, a + strlen(a));
  20. sort (b, b + strlen(b));
  21. for (y = 0, z = 0; y < strlen(a); ++y, ++z)
  22. {
  23. if (a[y] == b[z])
  24. m = m + 1;
  25. }
  26. if (m == strlen(a))
  27. printf ("YES\n");
  28. else
  29. printf ("NO\n");
  30. }
  31. return 0;
  32. }
Success #stdin #stdout 0s 3300KB
stdin
2
abb abc
aaa aaa
stdout
NO
YES