fork download
  1. // {{{ Template
  2. #include <bits/stdc++.h>
  3. #ifdef LOCAL
  4. #include "/Library/debug/debug.h"
  5. #define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
  6. #else
  7. #define debug(x...)
  8. #endif
  9.  
  10. using namespace std;
  11.  
  12. #define MAX 2e9
  13. #define MIN -2e9
  14. #define MOD 1000000007
  15. #define by(x) [](const auto& a, const auto& b) { return a.x < b.x; }
  16. #define INF 1e17
  17. #define PI acos(-1.0)
  18. #define mid(s,e) (s+(e-s)/2)
  19. #define clz(n) __builtin_clzll(n)
  20. #define nbOfBits(n) __builtin_popcountll(n)
  21. #define all(x) (x).begin(), (x).end()
  22. #define endl '\n'
  23. #define pb push_back
  24. #define sz(a) ((int)((a).size()))
  25. #define int long long
  26. #define double long double
  27. #define fi first
  28. #define se second
  29. #define getunique(v) {sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());}
  30.  
  31. // const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
  32. using vi = vector<int>;
  33. using vvi = vector<vi>;
  34. using vb = vector<bool>;
  35. using vvb = vector<vb>;
  36. using vd = vector<double>;
  37. using vvd = vector<vd>;
  38. using vs = vector<string>;
  39. using pii = pair<int, int>;
  40. using pdd = pair<double, double>;
  41. using vpii = vector<pii>;
  42. using vpdd = vector<pdd>;
  43.  
  44. /// }}}
  45.  
  46. unsigned seed = 0;
  47.  
  48.  
  49. int case_4() {
  50. auto bits = string(8,'0');
  51. for(int j=0;j<4;j++) {
  52. bits[j] = '1';
  53. }
  54. int x = 4;
  55. while(1) {
  56. bits = string(8,'0');
  57. for(int j=0;j<4+rand()%2;j++) {
  58. bits[j] = '1';
  59. }
  60. mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  61. shuffle(all(bits), rng);
  62. cout<<bits<<endl;
  63. cin>>x;
  64. if(x > 4) {
  65. cout<<"11111111"<<endl;
  66. cout << flush;
  67. cin>>x;
  68. }
  69. if(x != 4) {
  70. return x;
  71. }
  72. }
  73. }
  74.  
  75. int case_3() {
  76. auto bits = string(8,'0');
  77. for(int j=0;j<3;j++) {
  78. bits[j] = '1';
  79. }
  80. int x = 3;
  81. while(1) {
  82. bits = string(8,'0');
  83. for(int j=0;j<3+rand()%2;j++) {
  84. bits[j] = '1';
  85. }
  86. mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  87. shuffle(all(bits), rng);
  88. cout<<bits<<endl;
  89. cin>>x;
  90. if(x > 4) {
  91. cout<<"11111111"<<endl;
  92. cout << flush;
  93. cin>>x;
  94. }
  95. if(x != 3) {
  96. return x;
  97. }
  98. }
  99. }
  100.  
  101.  
  102. int case_2() {
  103. auto bits = string(8,'0');
  104. for(int j=0;j<2;j++) {
  105. bits[j] = '1';
  106. }
  107. int x = 2;
  108. while(1) {
  109. bits = string(8,'0');
  110. for(int j=0;j<2+rand()%2;j++) {
  111. bits[j] = '1';
  112. }
  113. mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  114. shuffle(all(bits), rng);
  115. cout<<bits<<endl;
  116. cin>>x;
  117. if(x > 4) {
  118. cout<<"11111111"<<endl;
  119. cout << flush;
  120. cin>>x;
  121. }
  122. if(x != 2) {
  123. return x;
  124. }
  125. }
  126. }
  127.  
  128. int case_1() {
  129. auto bits = string(8,'0');
  130. bits[0] = '1';
  131. int x = 1;
  132. while(1) {
  133. mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  134. shuffle(all(bits), rng);
  135. cout<<bits<<endl;
  136. cin>>x;
  137. if(x > 4) {
  138. cout<<"11111111"<<endl;
  139. cout << flush;
  140. cin>>x;
  141. }
  142. if(x != 1) {
  143. return x;
  144. }
  145. }
  146. }
  147.  
  148. bool solve() {
  149.  
  150. string bits(8,'1');
  151. cout<<bits<<endl;
  152. cout << flush;
  153. int x;
  154. cin>>x;
  155.  
  156. if(x > 4) {
  157. cout<<"11111111"<<endl;
  158. cout << flush;
  159. cin>>x;
  160. }
  161.  
  162. while(x != 0) {
  163. if(x < 0) {
  164. return 0;
  165. }
  166. if(x == 4) x = case_4();
  167. if(x == 3) x = case_3();
  168. if(x == 2) x = case_2();
  169. if(x == 1) x = case_1();
  170. }
  171. return 1;
  172. }
  173.  
  174. void preprocessing() {}
  175.  
  176. bool MULTI_TEST_CASES = 1;
  177.  
  178. // {{{ Main
  179. int32_t main() {
  180. cout << setprecision(20);
  181. cout<<fixed;
  182.  
  183. preprocessing();
  184.  
  185. int t=1;
  186. if(MULTI_TEST_CASES) cin>>t;
  187.  
  188. for(int i=1;i<=t;i++) {
  189. if(solve() == false) break;
  190. }
  191.  
  192. return 0;
  193. }
  194. // }}}
  195.  
  196.  
  197.  
Success #stdin #stdout 0s 5544KB
stdin
Standard input is empty
stdout
11111111