fork download
  1. #include <bits/stdc++.h>
  2. #define ldb long double
  3. //#define double ldb
  4. #define db double
  5. #define unomap unordered_map
  6. #define unoset unordered_set
  7. #define endl '\n'
  8. #define str string
  9. #define strstr stringstream
  10. #define sz(a) (int)a.size()
  11. #define ll long long
  12. //#define int ll
  13. #define pii pair <int, int>
  14. #define pll pair <ll, ll>
  15. #define Unique(a) a.resize(unique(all(a)) - a.begin())
  16. #define ull unsigned ll
  17. #define fir first
  18. #define sec second
  19. #define idc cin.ignore()
  20. #define lb lower_bound
  21. #define ub upper_bound
  22. #define all(s) s.begin(), s.end()
  23. #define rev reverse
  24. #define sigma ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  25. #define skibidi int main
  26. #define rizz signed main
  27. #define gcd __gcd
  28. #define pushb push_back
  29. #define popb pop_back
  30. #define pushf push_front
  31. #define popf pop_front
  32. #define mul2x(a, x) a << x
  33. #define div2x(a, x) a >> x
  34. #define lcm(a, b) (a / __gcd(a, b) * b)
  35. #define log_base(x, base) log(x) / log(base)
  36. #define debug clog << "No errors!"; exit(0);
  37. #define forw(i, a, b) for (int i = a; i <= b; ++i)
  38. #define forw2(i, a, b) for (ll i = a; i <= b; ++i)
  39. #define fors(i, a, b) for (int i = a; i >= b; --i)
  40. #define fors2(i, a, b) for (ll i = a; i >= b; --i)
  41. #define pqueue priority_queue
  42. #define sqrt sqrtl
  43. #define popcount __builtin_popcountll
  44. #define want_digit(x) cout << fixed << setprecision(x);
  45. #define excuting_time 1000.0 * clock() / CLOCKS_PER_SEC
  46. using namespace std;
  47. const int MOD = 1e9 + 7; // 998244353
  48. const int inf = 1e9;
  49. const ll INF = 1e18;
  50. const int N = 2e5;
  51. const int X = 2e6;
  52.  
  53. mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
  54. ll random(const ll &L, const ll &R)
  55. {
  56. return uniform_int_distribution<ll> (L, R) (rng);
  57. }
  58.  
  59. int n, a[N + 5], sum[X + 5], x, y;
  60. str d[X + 5];
  61. ldb s1, s2;
  62. void cook()
  63. {
  64. cin >> n >> x >> y;
  65. forw (i, 1, n) cin >> a[i];
  66.  
  67. int curr_x, curr_y;
  68. curr_x = curr_y = 1;
  69. forw (i, 1, x + y)
  70. {
  71. s1 = (ldb)curr_x / x;
  72. s2 = (ldb)curr_y / y;
  73. if (s1 == s2)
  74. {
  75. ++curr_x; ++curr_y;
  76. d[i] = "Both";
  77. }
  78. else if (s1 < s2)
  79. {
  80. d[i] = "D";
  81. ++curr_x;
  82. }
  83. else
  84. {
  85. d[i] = "C";
  86. ++curr_y;
  87. }
  88. }
  89.  
  90. forw (i, 1, x + y)
  91. sum[i] = sum[i - 1] + (d[i] == "Both" ? 2 : 1);
  92.  
  93. forw (i, 1, n)
  94. {
  95. a[i] %= x + y;
  96. if (!a[i])
  97. {
  98. cout << "Both\n";
  99. continue;
  100. }
  101.  
  102. cout << d[lb(sum + 1, sum + x + y + 1, a[i]) - sum] << endl;
  103. }
  104. }
  105.  
  106. skibidi()
  107. //rizz()
  108. {
  109. srand(time(NULL));
  110. sigma;
  111. #define name "test"
  112. /*
  113.   if (fopen(name".INP", "r"))
  114.   {
  115.   freopen(name".INP", "r", stdin);
  116.   freopen(name".OUT", "w", stdout);
  117.   }
  118.   */
  119. int numTest = 1;
  120. // cin >> numTest;
  121. while (numTest--)
  122. {
  123. cook();
  124. }
  125. return 0;
  126. }
  127.  
Success #stdin #stdout 0.02s 67068KB
stdin
4 1 2
5 6 10 12
stdout
Both
Both
C
Both