Submission #1197800

#TimeUsernameProblemLanguageResultExecution timeMemory
1197800nvc2k8Colors (BOI20_colors)C++20
0 / 100
0 ms436 KiB
#include <bits/stdc++.h> #define TASK "colors" #define INT_LIM (int) 2147483647 #define LL_LIM (long long) 9223372036854775807 #define endl '\n' #define mp make_pair #define pb push_back #define fi first #define se second #define BIT(i,x) (((i)>>(x))&1) #define FOR(i,a,b) for(int i = (a); i<=(b); i++) #define FORD(i,a,b) for(int i = (a); i>=(b); i--) #define ll long long #define pii pair<int,int> using namespace std; ///------------------------------------------/// ll n; #define ask(x) cout << "? " << (x) << endl; cout.flush(); #define answer(x) cout << "= " << (x) << endl; cout.flush(); void inp() { cin >> n; } ll ret = 0, lb = 0, rb = LL_LIM; int querycnt = 0; set<ll> dd; void solve() { int response; ll la = n-(1LL<<__lg(n)); ask(la); querycnt++; dd.insert(la); cin >> response; ll dir = 1; FORD(pos, 59, 0) { ll delta = ret+(1LL<<pos); if (delta>=n || delta<1) continue; if (la+dir*delta>n || la+dir*delta<1) dir = -dir; ll nw = la+dir*delta; // cout << delta-2068728389572138 << endl; cout.flush(); if (dd.count(nw)) assert(false); ask(nw); querycnt++; dd.insert(nw); la = nw; cin >> response; if (response==0) { ret+= (1LL<<pos); lb = max(lb, delta); } else { rb = min(rb, delta); } } if (querycnt>64) assert(false); answer(ret+1); } signed main() { ///--------------------------/// ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); if (fopen(TASK".INP","r")!=NULL) { freopen(TASK".INP","r",stdin); freopen(TASK".OUT","w",stdout); } ///--------------------------/// int NTEST = 1; //cin >> NTEST; while (NTEST--) { inp(); solve(); } return 0; } ///------------------------------------------///

Compilation message (stderr)

Colors.cpp: In function 'int main()':
Colors.cpp:73:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   73 |         freopen(TASK".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
Colors.cpp:74:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   74 |         freopen(TASK".OUT","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#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...