Advertisement
ghorardim

1033C

Oct 7th, 2018
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<math.h>
  4. #include<ctype.h>
  5. #include<stdlib.h>
  6. #include<cstdio>
  7. #include<cstring>
  8. #include<string>
  9. #include<cmath>
  10. #include<iostream>
  11. #include<cctype>
  12. #include<map>
  13. #include<stack>
  14. #include<cstdlib>
  15. #include<queue>
  16. #include<vector>
  17. #include<algorithm>
  18. #include<bitset>
  19. #include<algorithm>
  20. #include<set>
  21. #include<limits.h>
  22. #include <sstream>
  23.  
  24. //#include <bits/stdc++.h>
  25.  
  26.  
  27. using namespace std;
  28. typedef long int LD;
  29. typedef long long int LLD;
  30. typedef float F;
  31. typedef double LF;
  32. typedef unsigned int U;
  33. typedef unsigned long int LU;
  34. typedef unsigned long long int LLU;
  35. typedef char C;
  36.  
  37.  
  38. /*----------simple input section ------------ */
  39. #define sf scanf
  40. #define sfi(x) scanf("%d",&x)
  41. #define sfc(x) scanf("%c",&x)
  42. #define sfi2(x,y) scanf("%d%d",&x,&y)
  43. #define sfll2(x,y) scanf("%lld%lld",&x,&y)
  44. #define sfu2(x,y) scanf("%llu%llu",&x,&y)
  45. #define sfl(x) scanf("%ld",&x)
  46. #define sfll(x) scanf("%lld",&x)
  47. #define sfd(x) scanf("%lf",&x)
  48. #define sfu(x) scanf("%llu",&x)
  49. #define sfs(x) scanf("%s",x)
  50.  
  51.  
  52. /*----------simple input section ------------ */
  53. #define pf printf
  54. #define pfi(x) printf("%d\n",x)
  55. #define pfl(x) printf("%ld\n",x)
  56. #define pfll(x) printf("%lld\n",x)
  57. #define pfu(x) printf("%llu\n",x)
  58. #define pfs(x) printf("%s\n",x)
  59. #define pfc(x) printf("%c\n",x)
  60. #define pfd(x) printf("%lf\n",x)
  61.  
  62. /*----------file input section ------------ */
  63.  
  64. #define f_input freopen("input.txt","r",stdin);
  65. #define f_output freopen("output.txt","w",stdout);
  66.  
  67. #define pb(x) push_back(x)
  68. #define PI acos(-1.0)
  69. #define sq(x) (x)*(x)
  70. #define mem(x,y) memset(x,y,sizeof(x))
  71. #define TEST int cs,T;sfi(T);getchar();for(cs=1;cs<=T;cs++)
  72. #define nn printf("\n")
  73. // xx-> diagonal -> 8 horizontal/vertical->4
  74.  
  75. const int xx[] = {0, 1, 0, -1, -1, 1, -1, 1};
  76. const int yy[] = {1, 0, -1, 0, 1, 1, -1, -1};
  77.  
  78. // KX-> Knight moves
  79. const int kx[] = {-2, -1, 1, 2, 2, 1, -1, -2};
  80. const int ky[] = {1, 2, 2, 1, -1, -2, -2, -1};
  81.  
  82.  
  83. /******** debug **********/
  84. #define chk1 printf("hi......1 \n")
  85. #define chk2 printf("hi......2 \n")
  86.  
  87.  
  88. template<class T> T power(T N,T P)
  89. {
  90. return (P==0)? 1: N*power(N,P-1); //N^P
  91. }
  92.  
  93. #define mod 1000000007
  94. #define eps 10e-8
  95. #define sz 100005
  96. #define sz1 15
  97. #define sz2 3004
  98. #define sz3 5000004
  99. /******* start my code ********/
  100. int mark[sz];
  101. int arr[sz];
  102. int ans[sz];
  103. int main()
  104. {
  105. int i,j,k,n,mx,x;
  106. sfi(n);
  107.  
  108. for(i=1; i<=n; i++)
  109. {
  110. sfi(x);
  111. mark[x]=i;
  112. }
  113. if(n==1)
  114. {
  115. pfs("B");
  116. return 0;
  117. }
  118. ans[mark[n]]=0;
  119. ans[mark[1]]=1;
  120.  
  121. for(i=n-2; i>=2; i--)
  122. {
  123. ans[mark[i]]=0;
  124. for(j=i+1; j<=n; j++)
  125. {
  126.  
  127. if(abs(mark[j]-mark[i])%i==0 && !ans[mark[j]])
  128. {
  129.  
  130. ans[mark[i]]=1;
  131. break;
  132. }
  133. }
  134. }
  135. for(i=1; i<=n; i++)
  136. if(ans[i]==1) pf("A");
  137. else pf("B");
  138. nn;
  139. return 0;
  140. }
  141.  
  142. /*
  143. ABAAAABBBAABAAB
  144. ABAAAABBBAABAAB
  145.  
  146. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement