fork download
  1. #include <stdio.h>
  2. void quicksort(int x[],int first,int last){
  3. int pivot,j,temp,i;
  4.  
  5. if(first<last){
  6. pivot=first;
  7. i=first;
  8. j=last;
  9.  
  10. while(i<j){
  11. while(x[i]<=x[pivot]&&i<last)
  12. i++;
  13. while(x[j]>x[pivot])
  14. j--;
  15. if(i<j){
  16. temp=x[i];
  17. x[i]=x[j];
  18. x[j]=temp;
  19. }
  20. }
  21.  
  22. temp=x[pivot];
  23. x[pivot]=x[j];
  24. x[j]=temp;
  25. quicksort(x,first,j-1);
  26. quicksort(x,j+1,last);
  27.  
  28. }
  29. }
  30.  
  31. int main(void) {
  32. // your code goes here
  33. int t;
  34. scanf("%d",&t);
  35. while(t--)
  36. {
  37. long long n,m;
  38. scanf("%lld",&n);
  39. scanf("%lld",&m);
  40. long long new;
  41. int ar[12],i,j;
  42. int a=0;
  43. int n1=n,x,c=0;
  44. while(n1>0)
  45. {x=n1%10;
  46. if(x==0)
  47. c++;
  48. ar[a++]=n1%10;
  49. n1=n1/10;
  50. }
  51. quicksort(ar,0,a-1);
  52. int temp;
  53. if(ar[0]==0)
  54. {
  55. temp=ar[0];
  56. ar[0]=ar[c];
  57. ar[c]=temp;
  58. }
  59. new=0;
  60. for(i=0;i<a;i++)
  61. new=new*10+ar[i];
  62. if(new==m)
  63. printf("AC\n");
  64. else
  65. printf("WA\n");
  66. }
  67.  
  68. return 0;
  69. }
Success #stdin #stdout 0s 2012KB
stdin
3
666
0666
2
02
90812
010289
stdout
AC
AC
AC