Advertisement
PikMike

Untitled

Jun 22nd, 2016
399
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.63 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <iomanip>
  3. #include <iostream>
  4. #include <random>
  5.  
  6. #define pb push_back
  7. #define mp make_pair
  8. #define sz size
  9. #define ll long long
  10. #define ld long double
  11. #define fs first
  12. #define sc second
  13. #define forn(i, f, t) for(int i = f; i < t; i++)
  14. #define all(x) (x).begin(), (x).end()
  15. #define ins insert
  16.  
  17. const int INF = 2147483647;
  18. const int MOD = 1000000007;
  19. const ll INF64 = 9223372036854775807;
  20. const ld EPS = 1e-7;
  21.  
  22. using namespace std;
  23.  
  24. mt19937 gen(1);
  25. uniform_int_distribution<int> one_bit(0, 1);
  26. uniform_int_distribution<int> dist(0, INF);
  27.  
  28. int const N = 5000;
  29. int const K = 2000;
  30. int const X =  100;
  31. int const L =   25;
  32.  
  33.  
  34. void genSeq(vector<char> &res, int l, int r){
  35.     forn(i, l, r) res[i] = one_bit(gen);
  36. }
  37.  
  38.  
  39. int req(vector<char> &att){
  40.     forn(i, 0, N) printf("%d", (int)att[i]);
  41.     printf("\n");
  42.     fflush(stdout);
  43.     int res;
  44.     scanf("%d", &res);
  45.     return res - 1;
  46. }
  47.  
  48.  
  49. int main (void){
  50.     vector<char> atts(N, 0), temp(N, 0);
  51.     map<int, int> right;
  52.     int maxres = 0, lst = 0, cur = N;
  53.     genSeq(atts, 0, N);
  54.     forn(i, 0, L){
  55.         forn(j, 0, X / L){
  56.             genSeq(atts, N / L * i, N / L * (i + 1));
  57.  
  58.             for (auto it = right.begin(); it != right.end(); it++)
  59.                 atts[it->fs] = it->sc;
  60.  
  61.             cur = req(atts);
  62.             right[cur] = !atts[cur];
  63.             if (right.find(cur + 1) == right.end())
  64.                 right[cur + 1] = atts[cur + 1];
  65.  
  66.             if (cur > maxres){
  67.                 temp = atts;
  68.                 maxres = cur;
  69.             }
  70.         }
  71.         atts = temp;
  72.     }
  73.     return 0;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement