답안 #1051978

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1051978 2024-08-10T10:52:09 Z MrAndria Colors (BOI20_colors) C++14
컴파일 오류
0 ms 0 KB
#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

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(){
      |     ^~~~