Submission #1030467

# Submission time Handle Problem Language Result Execution time Memory
1030467 2024-07-22T05:32:25 Z 12345678 Colors (BOI20_colors) C++17
0 / 100
1 ms 344 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=1005;

int n, tmp, l, r, t, lst, x, ql[nx], qr[nx], used[nx], pv=-1;

int query(int x)
{
    cout<<"? "<<x<<endl;
    cin>>tmp;
    return tmp;
}

int main()
{
    cin>>n;
    //cin>>C;
    if (n==1) return cout<<"= "<<1, 0;
    for (int i=1; i<n; i++) ql[i]=1+(n-i)/2, qr[i]=n-((n-i)-1)/2; //cout<<"debug "<<i<<' '<<ql[i]<<' '<<qr[i]<<'\n';
    l=r=n;
    for (int i=60; ; i--)
    {
        l=max(1, r-i);
        if (l==r) return cout<<"= "<<l, 0;
        if (ql[l]==ql[l+1]) lst=ql[l], query(qr[l]), t=query(ql[l]), used[qr[l]]=used[ql[l]]=1;
        else lst=qr[l], query(ql[l]), t=query(qr[l]), used[qr[l]]=used[ql[l]]=1;
        if (t)
        {
            r=l;
            continue;
        }
        else
        {
            for (int j=l+1; j<r; j++)
            {
                if ((lst!=ql[j]&&used[ql[j]])||(lst!=qr[j]&&used[qr[j]]))
                {
                    l=j;
                    break;
                }
                if (lst==ql[j])
                {
                    lst=qr[j];
                    t=query(qr[j]);
                }
                else
                {
                    lst=ql[j];
                    t=query(ql[j]);
                }
                if (t) return cout<<"= "<<j, 0;
                if (j==r-1) return cout<<"= "<<r, 0;
            }
            
            if (l==r) return cout<<"= "<<l, 0;
            for (int j=1; j+l<=n; j++)
            {
                if (!used[j]&&!used[j+l])
                {
                    query(j);
                    t=query(j+l);
                    if (t) return cout<<"= "<<l<<'\n', 0;
                    else return cout<<"= "<<r<<'\n', 0;
                }
            }
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB OK (5 queries)
2 Correct 0 ms 344 KB OK (46 queries)
3 Correct 0 ms 344 KB OK (3 queries)
4 Correct 0 ms 344 KB OK (2 queries)
5 Correct 0 ms 344 KB OK (13 queries)
6 Correct 0 ms 344 KB OK (33 queries)
7 Correct 0 ms 344 KB OK (38 queries)
8 Correct 1 ms 344 KB OK (39 queries)
9 Correct 0 ms 344 KB OK (40 queries)
10 Correct 1 ms 344 KB OK (2 queries)
11 Correct 0 ms 344 KB OK (13 queries)
12 Correct 0 ms 344 KB OK (21 queries)
13 Correct 0 ms 344 KB OK (39 queries)
14 Correct 0 ms 340 KB OK (31 queries)
15 Correct 1 ms 344 KB OK (46 queries)
16 Correct 0 ms 344 KB OK (22 queries)
17 Correct 0 ms 344 KB OK (35 queries)
18 Correct 0 ms 344 KB OK (24 queries)
19 Correct 0 ms 344 KB OK (26 queries)
20 Correct 0 ms 344 KB OK (33 queries)
21 Correct 0 ms 344 KB OK (51 queries)
22 Incorrect 1 ms 344 KB Query limit exceeded
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB OK (5 queries)
2 Correct 0 ms 344 KB OK (46 queries)
3 Correct 0 ms 344 KB OK (3 queries)
4 Correct 0 ms 344 KB OK (2 queries)
5 Correct 0 ms 344 KB OK (13 queries)
6 Correct 0 ms 344 KB OK (33 queries)
7 Correct 0 ms 344 KB OK (38 queries)
8 Correct 1 ms 344 KB OK (39 queries)
9 Correct 0 ms 344 KB OK (40 queries)
10 Correct 1 ms 344 KB OK (2 queries)
11 Correct 0 ms 344 KB OK (13 queries)
12 Correct 0 ms 344 KB OK (21 queries)
13 Correct 0 ms 344 KB OK (39 queries)
14 Correct 0 ms 340 KB OK (31 queries)
15 Correct 1 ms 344 KB OK (46 queries)
16 Correct 0 ms 344 KB OK (22 queries)
17 Correct 0 ms 344 KB OK (35 queries)
18 Correct 0 ms 344 KB OK (24 queries)
19 Correct 0 ms 344 KB OK (26 queries)
20 Correct 0 ms 344 KB OK (33 queries)
21 Correct 0 ms 344 KB OK (51 queries)
22 Incorrect 1 ms 344 KB Query limit exceeded
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB OK (5 queries)
2 Correct 0 ms 344 KB OK (46 queries)
3 Correct 0 ms 344 KB OK (3 queries)
4 Correct 0 ms 344 KB OK (2 queries)
5 Correct 0 ms 344 KB OK (13 queries)
6 Correct 0 ms 344 KB OK (33 queries)
7 Correct 0 ms 344 KB OK (38 queries)
8 Correct 1 ms 344 KB OK (39 queries)
9 Correct 0 ms 344 KB OK (40 queries)
10 Correct 1 ms 344 KB OK (2 queries)
11 Correct 0 ms 344 KB OK (13 queries)
12 Correct 0 ms 344 KB OK (21 queries)
13 Correct 0 ms 344 KB OK (39 queries)
14 Correct 0 ms 340 KB OK (31 queries)
15 Correct 1 ms 344 KB OK (46 queries)
16 Correct 0 ms 344 KB OK (22 queries)
17 Correct 0 ms 344 KB OK (35 queries)
18 Correct 0 ms 344 KB OK (24 queries)
19 Correct 0 ms 344 KB OK (26 queries)
20 Correct 0 ms 344 KB OK (33 queries)
21 Correct 0 ms 344 KB OK (51 queries)
22 Incorrect 1 ms 344 KB Query limit exceeded
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB OK (5 queries)
2 Correct 0 ms 344 KB OK (46 queries)
3 Correct 0 ms 344 KB OK (3 queries)
4 Correct 0 ms 344 KB OK (2 queries)
5 Correct 0 ms 344 KB OK (13 queries)
6 Correct 0 ms 344 KB OK (33 queries)
7 Correct 0 ms 344 KB OK (38 queries)
8 Correct 1 ms 344 KB OK (39 queries)
9 Correct 0 ms 344 KB OK (40 queries)
10 Correct 1 ms 344 KB OK (2 queries)
11 Correct 0 ms 344 KB OK (13 queries)
12 Correct 0 ms 344 KB OK (21 queries)
13 Correct 0 ms 344 KB OK (39 queries)
14 Correct 0 ms 340 KB OK (31 queries)
15 Correct 1 ms 344 KB OK (46 queries)
16 Correct 0 ms 344 KB OK (22 queries)
17 Correct 0 ms 344 KB OK (35 queries)
18 Correct 0 ms 344 KB OK (24 queries)
19 Correct 0 ms 344 KB OK (26 queries)
20 Correct 0 ms 344 KB OK (33 queries)
21 Correct 0 ms 344 KB OK (51 queries)
22 Incorrect 1 ms 344 KB Query limit exceeded
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB OK (5 queries)
2 Correct 0 ms 344 KB OK (46 queries)
3 Correct 0 ms 344 KB OK (3 queries)
4 Correct 0 ms 344 KB OK (2 queries)
5 Correct 0 ms 344 KB OK (13 queries)
6 Correct 0 ms 344 KB OK (33 queries)
7 Correct 0 ms 344 KB OK (38 queries)
8 Correct 1 ms 344 KB OK (39 queries)
9 Correct 0 ms 344 KB OK (40 queries)
10 Correct 1 ms 344 KB OK (2 queries)
11 Correct 0 ms 344 KB OK (13 queries)
12 Correct 0 ms 344 KB OK (21 queries)
13 Correct 0 ms 344 KB OK (39 queries)
14 Correct 0 ms 340 KB OK (31 queries)
15 Correct 1 ms 344 KB OK (46 queries)
16 Correct 0 ms 344 KB OK (22 queries)
17 Correct 0 ms 344 KB OK (35 queries)
18 Correct 0 ms 344 KB OK (24 queries)
19 Correct 0 ms 344 KB OK (26 queries)
20 Correct 0 ms 344 KB OK (33 queries)
21 Correct 0 ms 344 KB OK (51 queries)
22 Incorrect 1 ms 344 KB Query limit exceeded
23 Halted 0 ms 0 KB -