Submission #257677

#TimeUsernameProblemLanguageResultExecution timeMemory
257677arnold518Colors (BOI20_colors)C++14
0 / 100
0 ms256 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; ll N; int query(ll x) { printf("? %d\n", x); fflush(stdout); ll t; scanf("%lld", &t); return t; } void answer(ll x) { printf("= %lld\n", x); fflush(stdout); exit(0); } int main() { ll i, j; scanf("%lld", &N); vector<ll> V, V2; for(i=1; i<=N; i++) V.push_back(i); int l=0, r=V.size()-1; while(1) { if(l>r) break; V2.push_back(V[l++]); if(l>r) break; V2.push_back(V[r--]); } reverse(V2.begin(), V2.end()); query(V2[0]); for(i=1; i<V2.size(); i++) if(query(V2[i])) break; answer(V2[i]-V2[i-1]); }

Compilation message (stderr)

Colors.cpp: In function 'int query(ll)':
Colors.cpp:12:20: warning: format '%d' expects argument of type 'int', but argument 2 has type 'll {aka long long int}' [-Wformat=]
  printf("? %d\n", x);
                    ^
Colors.cpp: In function 'int main()':
Colors.cpp:44:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(i=1; i<V2.size(); i++) if(query(V2[i])) break;
           ~^~~~~~~~~~
Colors.cpp:28:8: warning: unused variable 'j' [-Wunused-variable]
  ll i, j;
        ^
Colors.cpp: In function 'int query(ll)':
Colors.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &t);
  ~~~~~^~~~~~~~~~~~
Colors.cpp: In function 'int main()':
Colors.cpp:30:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &N);
  ~~~~~^~~~~~~~~~~~
#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...