# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
649651 | 2022-10-11T07:44:04 Z | DJeniUp | Colors (BOI20_colors) | C++17 | 1 ms | 208 KB |
#include "bits/stdc++.h" //#pragma GCC optimize("O3") using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll,ll>pairll; typedef long double ld; #define fr first #define sc second #define pb push_back #define INF 100000000007 #define endl '\n' #define MOD 998244353 #define A 31 #define N 500007 ll n; int main(){ cin>>n; if(n==1){ cout<<"= "<<1<<endl; cout.flush(); return 0; } ll a=1; ll b=1+n/3; ll c=n-(n-1)/3; ll d=n; ll f=0; ll f1=-1; cout<<"? "<<b<<endl; cout.flush(); ll x; cin>>x; while(1){ //cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl; if(a==b && c==d){ cout<<"= "<<d-a<<endl; cout.flush(); return 0; } if(f==-1){ f=0; cout<<"? "<<b<<endl; cout.flush(); cin>>x; if(x==0){ if(b==a && c==d){ cout<<"= "<<d-a+1<<endl; cout.flush(); return 0; }else{ f1=-1; c=(d+c+1)/2; } }else{ d=c-1; f1=-1; c=(b+d+1)/2; } }else{ f1=0; cout<<"? "<<c<<endl; cout.flush(); cin>>x; if(x==0){ if(b==a && c==d){ cout<<"= "<<d-a+1<<endl; cout.flush(); return 0; }else{ f=-1; b=(a+b)/2; } }else{ f=-1; a=b+1; b=(a+c)/2; } } } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | OK (6 queries) |
2 | Incorrect | 1 ms | 208 KB | Hair color 1 was used multiple times |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | OK (6 queries) |
2 | Incorrect | 1 ms | 208 KB | Hair color 1 was used multiple times |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | OK (6 queries) |
2 | Incorrect | 1 ms | 208 KB | Hair color 1 was used multiple times |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | OK (6 queries) |
2 | Incorrect | 1 ms | 208 KB | Hair color 1 was used multiple times |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | OK (6 queries) |
2 | Incorrect | 1 ms | 208 KB | Hair color 1 was used multiple times |
3 | Halted | 0 ms | 0 KB | - |