답안 #1107807

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1107807 2024-11-02T06:54:56 Z simona1230 Colors (BOI20_colors) C++17
0 / 100
1 ms 336 KB
#include <bits/stdc++.h>

using namespace std;
int n,j;
pair<int,int> p[200001];
void prec()
{
    int i=1;
    int l=1,r=n;
    while(l<r)
    {
        p[i]={l,r};
        if(l==n-r+1)l++;
        else r--;
        if(r-l+1==n/2)j=i;
        if(i%2==0)swap(p[i].first,p[i].second);
        i++;
    }
}

void solve()
{
    int i=j;
    cout<<"? "<<p[i].second<<endl;
    cout.flush();
    int x;
    cin>>x;
    cout<<"? "<<p[i].first<<endl;
    cout.flush();
    cin>>x;

    int curr=p[i].first;
    int d=abs(p[i].second-p[i].first);
    int h=n/2+n%2;

    if(x==1)
    {
        while(x==1)
        {
            d--;
            if(d==0)
            {
                cout<<"= "<<1<<endl;
                cout.flush();
                return;
            }
            int nxt=curr+d;
            if(curr>h)nxt=curr-d;
            cout<<"? "<<nxt<<endl;
            cout.flush();
            curr=nxt;
            cin>>x;
        }
        cout<<"= "<<d<<endl;
        cout.flush();
    }
    else
    {
        while(x==0)
        {
            d++;
            if(d==n)
            {
                cout<<"= "<<d<<endl;
                cout.flush();
                return;
            }

            int nxt=curr+d;
            if(curr>h)nxt=curr-d;
            cout<<"? "<<nxt<<endl;
            cout.flush();
            curr=nxt;
            cin>>x;
        }
        cout<<"= "<<d<<endl;
        cout.flush();
    }
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	prec();
	solve();
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB OK (3 queries)
2 Correct 1 ms 336 KB OK (23 queries)
3 Incorrect 1 ms 336 KB Wrong guess
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB OK (3 queries)
2 Correct 1 ms 336 KB OK (23 queries)
3 Incorrect 1 ms 336 KB Wrong guess
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB OK (3 queries)
2 Correct 1 ms 336 KB OK (23 queries)
3 Incorrect 1 ms 336 KB Wrong guess
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB OK (3 queries)
2 Correct 1 ms 336 KB OK (23 queries)
3 Incorrect 1 ms 336 KB Wrong guess
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB OK (3 queries)
2 Correct 1 ms 336 KB OK (23 queries)
3 Incorrect 1 ms 336 KB Wrong guess
4 Halted 0 ms 0 KB -