Advertisement
Guest User

Untitled

a guest
Dec 8th, 2015
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.33 KB | None | 0 0
  1. #pragma warning (disable : 4996)
  2. #pragma comment(linker, "/STACK:36777216")
  3.  
  4.  
  5.  
  6. #include <stdlib.h>
  7. #include <iostream>
  8. #include <vector>
  9. #include <string>
  10. #include <assert.h>
  11. #include <stack>
  12. #include <algorithm>
  13. #include <ios>
  14. #include <iostream>
  15. #include <fstream>
  16. #include <iomanip>
  17. #include <queue>
  18. #include <set>
  19. #include <functional>
  20. #include <cmath>
  21. #include <sstream>
  22. #include <map>
  23. #include <memory.h>
  24. #include <stdio.h>
  25. #include <cassert>
  26. #include <string.h>
  27. #include <deque>
  28. #include <ctime>
  29. #include <list>
  30. #include <unordered_set>
  31. #include <unordered_map>
  32.  
  33.  
  34. #define forn(i , n) for (int i = 0; i < n; ++i)
  35. #define down(i, n) for (int i = (n) - 1; i >= 0; --i)
  36.  
  37.  
  38. using namespace std;
  39.  
  40. typedef unsigned long long int u64;
  41. typedef long long int i64;
  42. typedef vector<int> vint;
  43. typedef vector<i64> vi64;
  44. typedef pair<int, int> pint;
  45. typedef pair<i64, i64> pi64;
  46.  
  47. #define FILE_NAME "file"
  48. #define CONTEST "kids"
  49. #define M_PI 3.14159265358979323846
  50. #define ALL(a) (a).begin(), (a).end()
  51. #define mp make_pair
  52.  
  53. typedef long long ll;
  54. typedef long double ld;
  55.  
  56. const ld EPS = 1e-9;
  57.  
  58. const int N = 10000001;
  59. const i64 INF = 1E8;
  60. const i64 MOD = 1000000007;
  61.  
  62. char invert(char c)
  63. {
  64.     if (c == '0')
  65.         return '1';
  66.     return '0';
  67. }
  68.  
  69. int counter = 500;
  70.  
  71. int main()
  72. {
  73.  
  74. //#ifdef FILE_INPUT
  75. //  freopen(FILE_NAME ".in", "r", stdin);
  76. //  freopen(FILE_NAME ".out", "w", stdout);
  77. //#else
  78. //  freopen(CONTEST ".in", "r", stdin);
  79. //  freopen(CONTEST ".out", "w", stdout);
  80. //#endif
  81.     srand(5);
  82.     int n;
  83.     cin >> n;
  84.     counter += n;
  85.     string s;
  86.     forn(i, n)
  87.     {
  88.         s += '0' + rand() % 2;
  89.     }
  90.  
  91.     int res = 0;
  92.     int pos = 0;
  93.     while (res != n / 2)
  94.     {
  95.         cout << s << endl;
  96.         --counter;
  97.         cin >> res;
  98.         if (res == n)
  99.         {
  100.             return 0;
  101.         }
  102.         if (res != n / 2)
  103.         {
  104.             s[pos] = invert(s[pos]);
  105.             ++pos;
  106.         }
  107.     }
  108.  
  109.     vint arr(n);
  110.  
  111.  
  112.     for (int i = 1; i < n; ++i)
  113.     {
  114.         string c = s;
  115.         c[0] = invert(c[0]);
  116.         c[i] = invert(c[i]);
  117.         cout << c << endl;
  118.         cin >> res;
  119.         if (res == n)
  120.         {
  121.             return 0;
  122.         }
  123.         if (res == n / 2)
  124.         {
  125.             arr[i] = 1;
  126.         }
  127.     }
  128.  
  129.     forn(i, n)
  130.     {
  131.         if (arr[i])
  132.         {
  133.             s[i] = invert(s[i]);
  134.         }
  135.     }
  136.  
  137.     cout << s << endl;
  138.     cin >> res;
  139.     if (res == n)
  140.         return 0;
  141.     forn(i, n)
  142.     {
  143.         s[i] = invert(s[i]);
  144.     }
  145.     cout << s << endl;
  146.     cin >> res;
  147.     if (res == n)
  148.         return 0;
  149.  
  150.     return 0;
  151. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement