fork download
  1. /*
  2. *DIV 2 C.
  3. *LINK:
  4. *nilabja10201992
  5. */
  6. #include <bits/stdc++.h>
  7. using namespace std;
  8.  
  9. #define inf (1<<30)
  10. #define INF (int)1e9
  11. #define EPS 1e-9
  12. #define PI 3.1415926535897932384626433832795
  13. #define MOD 1000000007
  14. #define MAX 1000010
  15.  
  16. int m,k,l;
  17. int dp[MAX];
  18. bool f(int a){
  19. if(a<=0)
  20. return 0;
  21. if(dp[a]!=-1)
  22. return dp[a];
  23. else{
  24. int arr[]={a-l,a-k,a-1};
  25. for(int i=0;i<3;i++)
  26. if(!f(arr[i]))
  27. return dp[a]=1;
  28. return dp[a]=0;
  29. }
  30. }
  31.  
  32. int main() {
  33. ios_base::sync_with_stdio(false);
  34. cin.tie(NULL);
  35. cin>>k>>l>>m;
  36. string str;
  37. int a;
  38. memset(dp,-1,sizeof(dp));
  39. for(int i=0;i<m;i++){
  40. cin>>a;
  41. if(f(a))
  42. str+='A';
  43. else
  44. str+='B';
  45. }
  46. cout<<str<<endl;
  47. //cout<<"Execution time : "<<tick();
  48. return 0;
  49. }
  50.  
Success #stdin #stdout 0s 19144KB
stdin
Standard input is empty
stdout