Submission #614174

#TimeUsernameProblemLanguageResultExecution timeMemory
614174cadmiumskyColors (BOI20_colors)C++14
0 / 100
1 ms208 KiB
#include <bits/stdc++.h> #define int long long using namespace std; int c; int last; int amog = 1; int u = 19; unordered_set<int> used; bool query(int x) { //#ifdef DLOCAL //int delta = abs(last - x); //last = x; //if(used.count(x + amog)) //assert(false); //used.insert(x + amog); //if(delta < c) //return 0; //else //return 1; //#endif cout << "? " << x + amog << endl; last = x; cin >> x; return x; } signed main() { int n; cin >> n; //#ifdef DLOCAL //cin >> c; //#endif n--; vector<int> bits; int msk = 0; for(int i = 60; i >= 0; i--) { if((1LL << i) & n) bits.push_back(i), (bits.size() % 2 == 0? msk |= (1LL << i): 0); } //for(auto x : bits) //cerr << x << ' '; //cerr << '\n'; int mine = 0, lelim = -1, toggle = 0; query(msk); for(int i = 0, x; i < bits.size(); i++) { if(i == bits.size() - 1) break; x = bits[i]; //cerr << toggle << '\n'; if(toggle) { if(!query(last - mine - (1 << x))) mine += (1LL << x); else break; } else { if(!query((1LL << x) + mine + last)) mine += (1LL << x); else break; } lelim = i; toggle ^= 1; } lelim++; assert(lelim != bits.size()); lelim = bits[lelim] - 1; if(lelim >= 0) { //lelim--; amog = 0; query((1LL << lelim)); toggle = 0; //lelim++; for(int i = lelim; i >= 0; i--) { if(toggle == 0) { if(!query(last + (1LL << i) + mine )) mine += (1LL << i); } else { if(!query(last - mine - (1LL << i))) mine += (1LL << i); } toggle ^= 1; } } cout << "= " << mine + 1 << endl; } // n = 24, C = 19

Compilation message (stderr)

Colors.cpp: In function 'int main()':
Colors.cpp:48:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |   for(int i = 0, x; i < bits.size(); i++) {
      |                     ~~^~~~~~~~~~~~~
Colors.cpp:49:10: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |     if(i == bits.size() - 1)
      |        ~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from Colors.cpp:1:
Colors.cpp:69:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |   assert(lelim != bits.size());
      |          ~~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...