Submission #357678

#TimeUsernameProblemLanguageResultExecution timeMemory
357678urd05Colors (BOI20_colors)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int main(void) { if (n<=1000) { long long n; scanf("%lld",&n); long long one=(n-1)/4+1; long long two=(3*n-1)/4+1; printf("? %lld\n",two); fflush(stdout); int got; scanf("%d",&got); printf("? %lld\n",one); fflush(stdout); scanf("%d",&got); long long ret; if (got==0) { int l=one-1+n-two; int d=two-one; ret=n; for(int i=0;i<l;i++) { long long nt=(two<one?two-1:two+1); printf("? %lld\n",nt); fflush(stdout); scanf("%d",&got); if (got==1) { ret=d+i+1; break; } two=one; one=nt; } } else { int l=two-one; ret=1; for(int i=l-1;i>0;i--) { int nt=(two<one?two+1:two-1); printf("? %lld\n",nt); fflush(stdout); scanf("%d",&got); if (got==0) { ret=i+1; break; } two=one; one=nt; } } printf("= %lld\n",ret); fflush(stdout); return 0; } long long n; scanf("%lld",&n); long long prev=0; long long d=0; int got; for(int i=29;i>0;i--) { long long nd=d+(1<<i); if (nd>=n) { continue; } long long one=(n+1)/2-nd/2; long long two=(n+1)/2+(nd+1)/2; printf("? %lld\n",two); fflush(stdout); scanf("%d",&got); printf("? %lld\n",one); fflush(stdout); scanf("%d",&got); if (got==0) { d+=(1<<i); } prev=one; } printf("? %lld\n",prev+d+1); fflush(stdout); scanf("%d",&got); if (got==0) { d++; } printf("= %lld\n",d); fflush(stdout); }

Compilation message (stderr)

Colors.cpp: In function 'int main()':
Colors.cpp:5:9: error: 'n' was not declared in this scope; did you mean 'yn'?
    5 |     if (n<=1000) {
      |         ^
      |         yn
Colors.cpp:6:19: error: redeclaration of 'long long int n'
    6 |         long long n;
      |                   ^
Colors.cpp:5:9: note: '<typeprefixerror>n' previously declared here
    5 |     if (n<=1000) {
      |         ^
Colors.cpp:40:30: warning: format '%lld' expects argument of type 'long long int', but argument 2 has type 'int' [-Wformat=]
   40 |                 printf("? %lld\n",nt);
      |                           ~~~^    ~~
      |                              |    |
      |                              |    int
      |                              long long int
      |                           %d
Colors.cpp:56:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   56 |     scanf("%lld",&n);
      |     ~~~~~^~~~~~~~~~~
Colors.cpp:69:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   69 |         scanf("%d",&got);
      |         ~~~~~^~~~~~~~~~~
Colors.cpp:72:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   72 |         scanf("%d",&got);
      |         ~~~~~^~~~~~~~~~~
Colors.cpp:80:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   80 |     scanf("%d",&got);
      |     ~~~~~^~~~~~~~~~~