Submission #1051978

#TimeUsernameProblemLanguageResultExecution timeMemory
1051978MrAndriaColors (BOI20_colors)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ff first; #define ss second #define pb push_back //#define int long long int k,l,r,n,ans; bool b1; int main(){ cin>>n; cout<<"? "<<1<<endl; cin>>b1; l=2; r=n; k=2; while(l<=r){ if(k%2==0){ cout<<"? "<<r<<endl; cin>>b1; if(b1==1){ ans=r-(l-1); }else{ break; } r--; }else{ cout<<"? "<<l<<endl; cin>>b1; if(b1==1){ ans=(r+1)-l; }else{ break; } l++; } k++; } cout<<"= "<<ans<<endl; }#include <bits/stdc++.h> using namespace std; #define ff first; #define ss second #define pb push_back //#define int long long int k,l,r,n,ans; bool b1; int main(){ cin>>n; cout<<"? "<<1<<endl; cin>>b1; l=2; r=n; k=2; while(l<=r){ if(k%2==0){ cout<<"? "<<r<<endl; cin>>b1; if(b1==1){ ans=r-(l-1); }else{ break; } r--; }else{ cout<<"? "<<l<<endl; cin>>b1; if(b1==1){ ans=(r+1)-l; }else{ break; } l++; } k++; } cout<<"= "<<ans<<endl; }

Compilation message (stderr)

Colors.cpp:41:2: error: stray '#' in program
   41 | }#include <bits/stdc++.h>
      |  ^
Colors.cpp:41:3: error: 'include' does not name a type
   41 | }#include <bits/stdc++.h>
      |   ^~~~~~~
Colors.cpp:47:5: error: redefinition of 'int k'
   47 | int k,l,r,n,ans;
      |     ^
Colors.cpp:7:5: note: 'int k' previously declared here
    7 | int k,l,r,n,ans;
      |     ^
Colors.cpp:47:7: error: redefinition of 'int l'
   47 | int k,l,r,n,ans;
      |       ^
Colors.cpp:7:7: note: 'int l' previously declared here
    7 | int k,l,r,n,ans;
      |       ^
Colors.cpp:47:9: error: redefinition of 'int r'
   47 | int k,l,r,n,ans;
      |         ^
Colors.cpp:7:9: note: 'int r' previously declared here
    7 | int k,l,r,n,ans;
      |         ^
Colors.cpp:47:11: error: redefinition of 'int n'
   47 | int k,l,r,n,ans;
      |           ^
Colors.cpp:7:11: note: 'int n' previously declared here
    7 | int k,l,r,n,ans;
      |           ^
Colors.cpp:47:13: error: redefinition of 'int ans'
   47 | int k,l,r,n,ans;
      |             ^~~
Colors.cpp:7:13: note: 'int ans' previously declared here
    7 | int k,l,r,n,ans;
      |             ^~~
Colors.cpp:48:6: error: redefinition of 'bool b1'
   48 | bool b1;
      |      ^~
Colors.cpp:8:6: note: 'bool b1' previously declared here
    8 | bool b1;
      |      ^~
Colors.cpp:49:5: error: redefinition of 'int main()'
   49 | int main(){
      |     ^~~~
Colors.cpp:9:5: note: 'int main()' previously defined here
    9 | int main(){
      |     ^~~~