Submission #357705

#TimeUsernameProblemLanguageResultExecution timeMemory
357705urd05Colors (BOI20_colors)C++14
22 / 100
2 ms512 KiB
#include <bits/stdc++.h> using namespace std; map<long long,int> mp; int main(void) { long long n; scanf("%lld",&n); if (n<=125) { 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 prev=0; long long d=1; int got; for(int i=29;i>0;i--) { long long nd=d+(1<<i)-1; if (nd>=n) { continue; } printf("%lld\n",nd); 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); mp[two-prev]=got; printf("? %lld\n",one); fflush(stdout); scanf("%d",&got); if (got==0) { d+=(1<<i); } prev=one; } if (mp.find(d)==mp.end()) { printf("? %lld\n",prev+d); fflush(stdout); scanf("%d",&got); } else { got=mp[d]; } if (got==0) { d++; } printf("= %lld\n",d); fflush(stdout); }

Compilation message (stderr)

Colors.cpp: In function 'int main()':
Colors.cpp:42:30: warning: format '%lld' expects argument of type 'long long int', but argument 2 has type 'int' [-Wformat=]
   42 |                 printf("? %lld\n",nt);
      |                           ~~~^    ~~
      |                              |    |
      |                              |    int
      |                              long long int
      |                           %d
Colors.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    8 |     scanf("%lld",&n);
      |     ~~~~~^~~~~~~~~~~
Colors.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   15 |         scanf("%d",&got);
      |         ~~~~~^~~~~~~~~~~
Colors.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |         scanf("%d",&got);
      |         ~~~~~^~~~~~~~~~~
Colors.cpp:28:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   28 |                 scanf("%d",&got);
      |                 ~~~~~^~~~~~~~~~~
Colors.cpp:44:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   44 |                 scanf("%d",&got);
      |                 ~~~~~^~~~~~~~~~~
Colors.cpp:70:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   70 |         scanf("%d",&got);
      |         ~~~~~^~~~~~~~~~~
Colors.cpp:74:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   74 |         scanf("%d",&got);
      |         ~~~~~^~~~~~~~~~~
Colors.cpp:83:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   83 |         scanf("%d",&got);
      |         ~~~~~^~~~~~~~~~~
#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...