fork(1) download
  1. // template : rjohari23
  2.  
  3. #include<iostream>
  4. #include<cstdio>
  5. #include<cmath>
  6. #include<cstring>
  7. #include<stdlib.h>
  8. #include<algorithm>
  9. #include<vector>
  10. #define getcx getchar_unlocked
  11. #define pc(x) putchar_unlocked(x);
  12. #ifndef ONLINE_JUDGE
  13. #define getcx getchar
  14. #endif
  15. using namespace std;
  16. #define clear(a) memset((a),0,sizeof(a))
  17. #define pb push_back
  18. #define SIZE(v) v.size()
  19. #define ull unsigned long long int
  20. #define lli long long int
  21. #define li long int
  22. #define ii int
  23. #define mod 1000000007
  24.  
  25. inline int inp()
  26. {
  27. int n=0;
  28. int ch=getcx();int sign=1;
  29. while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();}
  30.  
  31. while( ch >= '0' && ch <= '9' )
  32. n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
  33. return n*sign;
  34. }
  35.  
  36. inline long long in()
  37. {
  38. long long n=0;
  39. long long ch=getcx();long long sign=1;
  40. while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();}
  41.  
  42. while( ch >= '0' && ch <= '9' )
  43. n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
  44. return n*sign;
  45. }
  46.  
  47. inline void write (lli n)
  48. {
  49. lli N = n, rev, count = 0;
  50. rev = N;
  51. if (N == 0) { pc('0');return ;}
  52. while ((rev % 10) == 0) { count++; rev /= 10;} //obtain the count of the number of 0s
  53. rev = 0;
  54. while (N != 0) { rev = (rev<<3) + (rev<<1) + N % 10; N /= 10;} //store reverse of N in rev
  55. while (rev != 0) { pc(rev % 10 + '0'); rev /= 10;}
  56. while (count--) pc('0');
  57. }
  58.  
  59. /* http://d...content-available-to-author-only...f.com/questions/20106/fast-string-input */
  60. /* fast string input using getchar_unlocked */
  61. inline string ip()
  62. {
  63. string s = "";
  64. int temp=getchar_unlocked();
  65. while ( temp<'0'||temp>'9' )
  66. temp = getchar_unlocked();
  67. while ( temp>='0'&&temp<='9' )
  68. {
  69. s += (char)temp;
  70. temp = getchar_unlocked();
  71. }
  72. return s;
  73. }
  74.  
  75.  
  76. int main()
  77. {
  78. ii t;
  79.  
  80. t = inp();
  81. while ( t-- )
  82. {
  83. string s1,s2,ans;
  84.  
  85. s1 = ip(); s2 = ip();
  86.  
  87. ans = s1;
  88.  
  89. sort(s1.begin(),s1.end());
  90.  
  91. do
  92. {
  93. if ( s1[0]!='0' )
  94. ans = min(ans,s1);
  95. }
  96. while(next_permutation(s1.begin(),s1.end()));
  97.  
  98. if ( s2==ans )
  99. printf("AC\n");
  100. else
  101. printf("WA\n");
  102. }
  103. return 0;
  104. }
Success #stdin #stdout 0s 2868KB
stdin
2
310
103
1
2
stdout
AC
WA