Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- #include<math.h>
- #include<ctype.h>
- #include<stdlib.h>
- #include<cstdio>
- #include<cstring>
- #include<string>
- #include<cmath>
- #include<iostream>
- #include<cctype>
- #include<map>
- #include<stack>
- #include<cstdlib>
- #include<queue>
- #include<vector>
- #include<algorithm>
- #include<bitset>
- #include<algorithm>
- #include<set>
- #include<limits.h>
- #include <sstream>
- //#include <bits/stdc++.h>
- using namespace std;
- typedef long int LD;
- typedef long long int LLD;
- typedef float F;
- typedef double LF;
- typedef unsigned int U;
- typedef unsigned long int LU;
- typedef unsigned long long int LLU;
- typedef char C;
- /*----------simple input section ------------ */
- #define sf scanf
- #define sfi(x) scanf("%d",&x)
- #define sfc(x) scanf("%c",&x)
- #define sfi2(x,y) scanf("%d%d",&x,&y)
- #define sfll2(x,y) scanf("%lld%lld",&x,&y)
- #define sfu2(x,y) scanf("%llu%llu",&x,&y)
- #define sfl(x) scanf("%ld",&x)
- #define sfll(x) scanf("%lld",&x)
- #define sfd(x) scanf("%lf",&x)
- #define sfu(x) scanf("%llu",&x)
- #define sfs(x) scanf("%s",x)
- /*----------simple input section ------------ */
- #define pf printf
- #define pfi(x) printf("%d\n",x)
- #define pfl(x) printf("%ld\n",x)
- #define pfll(x) printf("%lld\n",x)
- #define pfu(x) printf("%llu\n",x)
- #define pfs(x) printf("%s\n",x)
- #define pfc(x) printf("%c\n",x)
- #define pfd(x) printf("%lf\n",x)
- /*----------file input section ------------ */
- #define f_input freopen("input.txt","r",stdin);
- #define f_output freopen("output.txt","w",stdout);
- #define pb(x) push_back(x)
- #define PI acos(-1.0)
- #define sq(x) (x)*(x)
- #define mem(x,y) memset(x,y,sizeof(x))
- #define TEST int cs,T;sfi(T);getchar();for(cs=1;cs<=T;cs++)
- #define nn printf("\n")
- // xx-> diagonal -> 8 horizontal/vertical->4
- const int xx[] = {0, 1, 0, -1, -1, 1, -1, 1};
- const int yy[] = {1, 0, -1, 0, 1, 1, -1, -1};
- // KX-> Knight moves
- const int kx[] = {-2, -1, 1, 2, 2, 1, -1, -2};
- const int ky[] = {1, 2, 2, 1, -1, -2, -2, -1};
- /******** debug **********/
- #define chk1 printf("hi......1 \n")
- #define chk2 printf("hi......2 \n")
- template<class T> T power(T N,T P)
- {
- return (P==0)? 1: N*power(N,P-1); //N^P
- }
- #define mod 1000000007
- #define eps 10e-8
- #define sz 100005
- #define sz1 15
- #define sz2 3004
- #define sz3 5000004
- /******* start my code ********/
- int mark[sz];
- int arr[sz];
- int ans[sz];
- int main()
- {
- int i,j,k,n,mx,x;
- sfi(n);
- for(i=1; i<=n; i++)
- {
- sfi(x);
- mark[x]=i;
- }
- if(n==1)
- {
- pfs("B");
- return 0;
- }
- ans[mark[n]]=0;
- ans[mark[1]]=1;
- for(i=n-2; i>=2; i--)
- {
- ans[mark[i]]=0;
- for(j=i+1; j<=n; j++)
- {
- if(abs(mark[j]-mark[i])%i==0 && !ans[mark[j]])
- {
- ans[mark[i]]=1;
- break;
- }
- }
- }
- for(i=1; i<=n; i++)
- if(ans[i]==1) pf("A");
- else pf("B");
- nn;
- return 0;
- }
- /*
- ABAAAABBBAABAAB
- ABAAAABBBAABAAB
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement