답안 #489748

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
489748 2021-11-24T07:34:06 Z gabrupro Colors (BOI20_colors) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

#define ar array
#define ll long long
#define pb push_back
#define bg begin()
#define ed end()
#define fi for(int i=0;i<n;i++)

const int MAX_N = 1e5 + 1;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    ll n;cin>>n;
    ll l=1, r=n;
    int qwe
    cout<<"? "<<1<<endl;cin>>qwe;
    bool done=false;
    while(abs(r-l)>0){
        cout<<"? "<<r<<endl;
        int ans;cin>>ans;
        int mid=(l+r)/2; int rd=r;
        if(ans){r=mid;}
        else{
            if(r>l){r=l-mid;}
            else{r=l+mid;}
        }
        l=rd;
        if(abs(l-r)>n){cout<<"= "<<n<<endl;done=true;break}
    }
    if(!done){cout<<"= "<<l<<endl;}



}

Compilation message

Colors.cpp: In function 'int main()':
Colors.cpp:24:5: error: expected initializer before 'cout'
   24 |     cout<<"? "<<1<<endl;cin>>qwe;
      |     ^~~~
Colors.cpp:24:30: error: 'qwe' was not declared in this scope
   24 |     cout<<"? "<<1<<endl;cin>>qwe;
      |                              ^~~
Colors.cpp:36:59: error: expected ';' before '}' token
   36 |         if(abs(l-r)>n){cout<<"= "<<n<<endl;done=true;break}
      |                                                           ^
      |                                                           ;