Submission #720382

# Submission time Handle Problem Language Result Execution time Memory
720382 2023-04-08T06:08:58 Z n0sk1ll Colors (BOI20_colors) C++14
9 / 100
1 ms 332 KB
#include <bits/stdc++.h>

#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0)
#define mp make_pair
#define xx first
#define yy second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(x) x.begin(),x.end()
#define ff(i,a,b) for (int i = a; i < b; i++)
#define fff(i,a,b) for (int i = a; i <= b; i++)
#define bff(i,a,b) for (int i = b-1; i >= a; i--)
#define bfff(i,a,b) for (int i = b; i >= a; i--)

using namespace std;
long double typedef ld;
unsigned int typedef ui;
long long int typedef li;
pair<int,int> typedef pii;
pair<li,li> typedef pli;
pair<ld,ld> typedef pld;
vector<vector<int>> typedef graph;
unsigned long long int typedef ull;
//const int mod = 998244353;
const int mod = 1000000007;







//Note to self: Check for overflow

bool ask(li x) //da li njen decko noticuje promenu
{
    cout<<"? "<<x<<endl;
    bool verd; cin>>verd; return verd;
}

li solvebs(li n)
{
    li l=0,r=n;
    li p=(n+2)/3,k; ask(p);
    bool idedesno=true;

    while (r-l>3) //koliko mu je dozvoljeno da skace
    {
        if (idedesno) k=(l+r+1)/2;
        else k=(l+r)/2;

        li q;
        if (idedesno) q=p+k;
        else q=p-k;
        if (ask(q)) r=k;
        else l=k;
        idedesno=!idedesno;
        p=q;
    }

    //cout<<"izaso iz binarne: "<<l<<" "<<r<<": "<<k<<endl;

    if (l==k)
    {
        while(true)
        {
            k++;
            if (k>n-1) return n;
            li q;
            if (idedesno) q=p+k;
            else q=p-k;
            if (ask(q)) return k;
            idedesno=!idedesno;
            p=q;
        }
    }
    else
    {
        while (true)
        {
            k--;
            if (k==0) return 1;
            li q;
            if (idedesno) q=p+k;
            else q=p-k;
            if (!ask(q)) return k+1;
            idedesno=!idedesno;
            p=q;
        }
    }
}

int main()
{
    FAST;

    li n; cin>>n;


    if (n<=64)
    {
        int l=1,r=n;
        ask(l++);
        while (r-l>=0)
        {
            if (!ask(r)) return cout<<"= "<<r-l+2,0;
            r--;

            if (r-l>=0)
            {
                if (!ask(l)) return cout<<"= "<<r-l+2,0;
                l++;
            }
        }
        cout<<"= 1";
    }
    else
    {
        li ans=solvebs(n);
        cout<<"= "<<ans<<"\n";
    }
}

//Note to self: Check for overflow

Compilation message

Colors.cpp: In function 'li solvebs(li)':
Colors.cpp:83:14: warning: 'k' may be used uninitialized in this function [-Wmaybe-uninitialized]
   83 |             k--;
      |             ~^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB OK (5 queries)
2 Correct 1 ms 208 KB OK (6 queries)
3 Correct 0 ms 208 KB OK (10 queries)
4 Correct 1 ms 208 KB OK (26 queries)
5 Correct 1 ms 208 KB OK (13 queries)
6 Correct 1 ms 208 KB OK (26 queries)
7 Correct 1 ms 208 KB OK (17 queries)
8 Correct 0 ms 208 KB OK (7 queries)
9 Correct 0 ms 208 KB OK (9 queries)
10 Correct 1 ms 208 KB OK (11 queries)
11 Correct 1 ms 208 KB OK (4 queries)
12 Correct 1 ms 208 KB OK (5 queries)
13 Correct 1 ms 208 KB OK (11 queries)
14 Correct 1 ms 208 KB OK (16 queries)
15 Correct 1 ms 208 KB OK (11 queries)
16 Correct 1 ms 208 KB OK (34 queries)
17 Correct 1 ms 208 KB OK (2 queries)
18 Correct 1 ms 208 KB OK (16 queries)
19 Correct 1 ms 208 KB OK (3 queries)
20 Correct 1 ms 208 KB OK (31 queries)
21 Correct 1 ms 208 KB OK (9 queries)
22 Correct 1 ms 208 KB OK (2 queries)
23 Correct 1 ms 208 KB OK (2 queries)
24 Correct 1 ms 208 KB OK (2 queries)
25 Correct 0 ms 208 KB OK (3 queries)
26 Correct 1 ms 208 KB OK (3 queries)
27 Correct 0 ms 208 KB OK (2 queries)
28 Correct 0 ms 208 KB OK (3 queries)
29 Correct 0 ms 208 KB OK (4 queries)
30 Correct 0 ms 284 KB OK (4 queries)
31 Correct 0 ms 208 KB OK (2 queries)
32 Correct 1 ms 208 KB OK (3 queries)
33 Correct 1 ms 208 KB OK (4 queries)
34 Correct 1 ms 208 KB OK (5 queries)
35 Correct 0 ms 208 KB OK (5 queries)
36 Correct 0 ms 208 KB OK (2 queries)
37 Correct 0 ms 208 KB OK (3 queries)
38 Correct 1 ms 208 KB OK (4 queries)
39 Correct 1 ms 208 KB OK (5 queries)
40 Correct 1 ms 208 KB OK (6 queries)
41 Correct 1 ms 208 KB OK (6 queries)
42 Correct 1 ms 208 KB OK (2 queries)
43 Correct 0 ms 208 KB OK (3 queries)
44 Correct 0 ms 208 KB OK (4 queries)
45 Correct 1 ms 208 KB OK (5 queries)
46 Correct 0 ms 208 KB OK (6 queries)
47 Correct 1 ms 332 KB OK (7 queries)
48 Correct 0 ms 208 KB OK (7 queries)
49 Correct 0 ms 208 KB OK (2 queries)
50 Correct 1 ms 208 KB OK (3 queries)
51 Correct 0 ms 208 KB OK (4 queries)
52 Correct 1 ms 208 KB OK (5 queries)
53 Correct 1 ms 212 KB OK (6 queries)
54 Correct 1 ms 208 KB OK (7 queries)
55 Correct 0 ms 208 KB OK (8 queries)
56 Correct 1 ms 208 KB OK (8 queries)
57 Correct 0 ms 208 KB OK (3 queries)
58 Correct 0 ms 208 KB OK (2 queries)
59 Correct 1 ms 208 KB OK (3 queries)
60 Correct 0 ms 208 KB OK (2 queries)
61 Correct 1 ms 208 KB OK (63 queries)
62 Correct 1 ms 208 KB OK (2 queries)
63 Correct 1 ms 208 KB OK (63 queries)
64 Correct 1 ms 208 KB OK (3 queries)
65 Correct 1 ms 208 KB OK (62 queries)
66 Correct 1 ms 208 KB OK (4 queries)
67 Correct 1 ms 308 KB OK (61 queries)
68 Correct 1 ms 208 KB OK (5 queries)
69 Correct 1 ms 208 KB OK (60 queries)
70 Correct 0 ms 208 KB OK (6 queries)
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB OK (5 queries)
2 Correct 1 ms 208 KB OK (6 queries)
3 Correct 0 ms 208 KB OK (10 queries)
4 Correct 1 ms 208 KB OK (26 queries)
5 Correct 1 ms 208 KB OK (13 queries)
6 Correct 1 ms 208 KB OK (26 queries)
7 Correct 1 ms 208 KB OK (17 queries)
8 Correct 0 ms 208 KB OK (7 queries)
9 Correct 0 ms 208 KB OK (9 queries)
10 Correct 1 ms 208 KB OK (11 queries)
11 Correct 1 ms 208 KB OK (4 queries)
12 Correct 1 ms 208 KB OK (5 queries)
13 Correct 1 ms 208 KB OK (11 queries)
14 Correct 1 ms 208 KB OK (16 queries)
15 Correct 1 ms 208 KB OK (11 queries)
16 Correct 1 ms 208 KB OK (34 queries)
17 Correct 1 ms 208 KB OK (2 queries)
18 Correct 1 ms 208 KB OK (16 queries)
19 Correct 1 ms 208 KB OK (3 queries)
20 Correct 1 ms 208 KB OK (31 queries)
21 Correct 1 ms 208 KB OK (9 queries)
22 Correct 1 ms 208 KB OK (2 queries)
23 Correct 1 ms 208 KB OK (2 queries)
24 Correct 1 ms 208 KB OK (2 queries)
25 Correct 0 ms 208 KB OK (3 queries)
26 Correct 1 ms 208 KB OK (3 queries)
27 Correct 0 ms 208 KB OK (2 queries)
28 Correct 0 ms 208 KB OK (3 queries)
29 Correct 0 ms 208 KB OK (4 queries)
30 Correct 0 ms 284 KB OK (4 queries)
31 Correct 0 ms 208 KB OK (2 queries)
32 Correct 1 ms 208 KB OK (3 queries)
33 Correct 1 ms 208 KB OK (4 queries)
34 Correct 1 ms 208 KB OK (5 queries)
35 Correct 0 ms 208 KB OK (5 queries)
36 Correct 0 ms 208 KB OK (2 queries)
37 Correct 0 ms 208 KB OK (3 queries)
38 Correct 1 ms 208 KB OK (4 queries)
39 Correct 1 ms 208 KB OK (5 queries)
40 Correct 1 ms 208 KB OK (6 queries)
41 Correct 1 ms 208 KB OK (6 queries)
42 Correct 1 ms 208 KB OK (2 queries)
43 Correct 0 ms 208 KB OK (3 queries)
44 Correct 0 ms 208 KB OK (4 queries)
45 Correct 1 ms 208 KB OK (5 queries)
46 Correct 0 ms 208 KB OK (6 queries)
47 Correct 1 ms 332 KB OK (7 queries)
48 Correct 0 ms 208 KB OK (7 queries)
49 Correct 0 ms 208 KB OK (2 queries)
50 Correct 1 ms 208 KB OK (3 queries)
51 Correct 0 ms 208 KB OK (4 queries)
52 Correct 1 ms 208 KB OK (5 queries)
53 Correct 1 ms 212 KB OK (6 queries)
54 Correct 1 ms 208 KB OK (7 queries)
55 Correct 0 ms 208 KB OK (8 queries)
56 Correct 1 ms 208 KB OK (8 queries)
57 Correct 0 ms 208 KB OK (3 queries)
58 Correct 0 ms 208 KB OK (2 queries)
59 Correct 1 ms 208 KB OK (3 queries)
60 Correct 0 ms 208 KB OK (2 queries)
61 Correct 1 ms 208 KB OK (63 queries)
62 Correct 1 ms 208 KB OK (2 queries)
63 Correct 1 ms 208 KB OK (63 queries)
64 Correct 1 ms 208 KB OK (3 queries)
65 Correct 1 ms 208 KB OK (62 queries)
66 Correct 1 ms 208 KB OK (4 queries)
67 Correct 1 ms 308 KB OK (61 queries)
68 Correct 1 ms 208 KB OK (5 queries)
69 Correct 1 ms 208 KB OK (60 queries)
70 Correct 0 ms 208 KB OK (6 queries)
71 Correct 0 ms 208 KB OK (8 queries)
72 Runtime error 1 ms 208 KB Execution killed with signal 13
73 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB OK (5 queries)
2 Correct 1 ms 208 KB OK (6 queries)
3 Correct 0 ms 208 KB OK (10 queries)
4 Correct 1 ms 208 KB OK (26 queries)
5 Correct 1 ms 208 KB OK (13 queries)
6 Correct 1 ms 208 KB OK (26 queries)
7 Correct 1 ms 208 KB OK (17 queries)
8 Correct 0 ms 208 KB OK (7 queries)
9 Correct 0 ms 208 KB OK (9 queries)
10 Correct 1 ms 208 KB OK (11 queries)
11 Correct 1 ms 208 KB OK (4 queries)
12 Correct 1 ms 208 KB OK (5 queries)
13 Correct 1 ms 208 KB OK (11 queries)
14 Correct 1 ms 208 KB OK (16 queries)
15 Correct 1 ms 208 KB OK (11 queries)
16 Correct 1 ms 208 KB OK (34 queries)
17 Correct 1 ms 208 KB OK (2 queries)
18 Correct 1 ms 208 KB OK (16 queries)
19 Correct 1 ms 208 KB OK (3 queries)
20 Correct 1 ms 208 KB OK (31 queries)
21 Correct 1 ms 208 KB OK (9 queries)
22 Correct 1 ms 208 KB OK (2 queries)
23 Correct 1 ms 208 KB OK (2 queries)
24 Correct 1 ms 208 KB OK (2 queries)
25 Correct 0 ms 208 KB OK (3 queries)
26 Correct 1 ms 208 KB OK (3 queries)
27 Correct 0 ms 208 KB OK (2 queries)
28 Correct 0 ms 208 KB OK (3 queries)
29 Correct 0 ms 208 KB OK (4 queries)
30 Correct 0 ms 284 KB OK (4 queries)
31 Correct 0 ms 208 KB OK (2 queries)
32 Correct 1 ms 208 KB OK (3 queries)
33 Correct 1 ms 208 KB OK (4 queries)
34 Correct 1 ms 208 KB OK (5 queries)
35 Correct 0 ms 208 KB OK (5 queries)
36 Correct 0 ms 208 KB OK (2 queries)
37 Correct 0 ms 208 KB OK (3 queries)
38 Correct 1 ms 208 KB OK (4 queries)
39 Correct 1 ms 208 KB OK (5 queries)
40 Correct 1 ms 208 KB OK (6 queries)
41 Correct 1 ms 208 KB OK (6 queries)
42 Correct 1 ms 208 KB OK (2 queries)
43 Correct 0 ms 208 KB OK (3 queries)
44 Correct 0 ms 208 KB OK (4 queries)
45 Correct 1 ms 208 KB OK (5 queries)
46 Correct 0 ms 208 KB OK (6 queries)
47 Correct 1 ms 332 KB OK (7 queries)
48 Correct 0 ms 208 KB OK (7 queries)
49 Correct 0 ms 208 KB OK (2 queries)
50 Correct 1 ms 208 KB OK (3 queries)
51 Correct 0 ms 208 KB OK (4 queries)
52 Correct 1 ms 208 KB OK (5 queries)
53 Correct 1 ms 212 KB OK (6 queries)
54 Correct 1 ms 208 KB OK (7 queries)
55 Correct 0 ms 208 KB OK (8 queries)
56 Correct 1 ms 208 KB OK (8 queries)
57 Correct 0 ms 208 KB OK (3 queries)
58 Correct 0 ms 208 KB OK (2 queries)
59 Correct 1 ms 208 KB OK (3 queries)
60 Correct 0 ms 208 KB OK (2 queries)
61 Correct 1 ms 208 KB OK (63 queries)
62 Correct 1 ms 208 KB OK (2 queries)
63 Correct 1 ms 208 KB OK (63 queries)
64 Correct 1 ms 208 KB OK (3 queries)
65 Correct 1 ms 208 KB OK (62 queries)
66 Correct 1 ms 208 KB OK (4 queries)
67 Correct 1 ms 308 KB OK (61 queries)
68 Correct 1 ms 208 KB OK (5 queries)
69 Correct 1 ms 208 KB OK (60 queries)
70 Correct 0 ms 208 KB OK (6 queries)
71 Correct 0 ms 208 KB OK (8 queries)
72 Runtime error 1 ms 208 KB Execution killed with signal 13
73 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB OK (5 queries)
2 Correct 1 ms 208 KB OK (6 queries)
3 Correct 0 ms 208 KB OK (10 queries)
4 Correct 1 ms 208 KB OK (26 queries)
5 Correct 1 ms 208 KB OK (13 queries)
6 Correct 1 ms 208 KB OK (26 queries)
7 Correct 1 ms 208 KB OK (17 queries)
8 Correct 0 ms 208 KB OK (7 queries)
9 Correct 0 ms 208 KB OK (9 queries)
10 Correct 1 ms 208 KB OK (11 queries)
11 Correct 1 ms 208 KB OK (4 queries)
12 Correct 1 ms 208 KB OK (5 queries)
13 Correct 1 ms 208 KB OK (11 queries)
14 Correct 1 ms 208 KB OK (16 queries)
15 Correct 1 ms 208 KB OK (11 queries)
16 Correct 1 ms 208 KB OK (34 queries)
17 Correct 1 ms 208 KB OK (2 queries)
18 Correct 1 ms 208 KB OK (16 queries)
19 Correct 1 ms 208 KB OK (3 queries)
20 Correct 1 ms 208 KB OK (31 queries)
21 Correct 1 ms 208 KB OK (9 queries)
22 Correct 1 ms 208 KB OK (2 queries)
23 Correct 1 ms 208 KB OK (2 queries)
24 Correct 1 ms 208 KB OK (2 queries)
25 Correct 0 ms 208 KB OK (3 queries)
26 Correct 1 ms 208 KB OK (3 queries)
27 Correct 0 ms 208 KB OK (2 queries)
28 Correct 0 ms 208 KB OK (3 queries)
29 Correct 0 ms 208 KB OK (4 queries)
30 Correct 0 ms 284 KB OK (4 queries)
31 Correct 0 ms 208 KB OK (2 queries)
32 Correct 1 ms 208 KB OK (3 queries)
33 Correct 1 ms 208 KB OK (4 queries)
34 Correct 1 ms 208 KB OK (5 queries)
35 Correct 0 ms 208 KB OK (5 queries)
36 Correct 0 ms 208 KB OK (2 queries)
37 Correct 0 ms 208 KB OK (3 queries)
38 Correct 1 ms 208 KB OK (4 queries)
39 Correct 1 ms 208 KB OK (5 queries)
40 Correct 1 ms 208 KB OK (6 queries)
41 Correct 1 ms 208 KB OK (6 queries)
42 Correct 1 ms 208 KB OK (2 queries)
43 Correct 0 ms 208 KB OK (3 queries)
44 Correct 0 ms 208 KB OK (4 queries)
45 Correct 1 ms 208 KB OK (5 queries)
46 Correct 0 ms 208 KB OK (6 queries)
47 Correct 1 ms 332 KB OK (7 queries)
48 Correct 0 ms 208 KB OK (7 queries)
49 Correct 0 ms 208 KB OK (2 queries)
50 Correct 1 ms 208 KB OK (3 queries)
51 Correct 0 ms 208 KB OK (4 queries)
52 Correct 1 ms 208 KB OK (5 queries)
53 Correct 1 ms 212 KB OK (6 queries)
54 Correct 1 ms 208 KB OK (7 queries)
55 Correct 0 ms 208 KB OK (8 queries)
56 Correct 1 ms 208 KB OK (8 queries)
57 Correct 0 ms 208 KB OK (3 queries)
58 Correct 0 ms 208 KB OK (2 queries)
59 Correct 1 ms 208 KB OK (3 queries)
60 Correct 0 ms 208 KB OK (2 queries)
61 Correct 1 ms 208 KB OK (63 queries)
62 Correct 1 ms 208 KB OK (2 queries)
63 Correct 1 ms 208 KB OK (63 queries)
64 Correct 1 ms 208 KB OK (3 queries)
65 Correct 1 ms 208 KB OK (62 queries)
66 Correct 1 ms 208 KB OK (4 queries)
67 Correct 1 ms 308 KB OK (61 queries)
68 Correct 1 ms 208 KB OK (5 queries)
69 Correct 1 ms 208 KB OK (60 queries)
70 Correct 0 ms 208 KB OK (6 queries)
71 Correct 0 ms 208 KB OK (8 queries)
72 Runtime error 1 ms 208 KB Execution killed with signal 13
73 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB OK (5 queries)
2 Correct 1 ms 208 KB OK (6 queries)
3 Correct 0 ms 208 KB OK (10 queries)
4 Correct 1 ms 208 KB OK (26 queries)
5 Correct 1 ms 208 KB OK (13 queries)
6 Correct 1 ms 208 KB OK (26 queries)
7 Correct 1 ms 208 KB OK (17 queries)
8 Correct 0 ms 208 KB OK (7 queries)
9 Correct 0 ms 208 KB OK (9 queries)
10 Correct 1 ms 208 KB OK (11 queries)
11 Correct 1 ms 208 KB OK (4 queries)
12 Correct 1 ms 208 KB OK (5 queries)
13 Correct 1 ms 208 KB OK (11 queries)
14 Correct 1 ms 208 KB OK (16 queries)
15 Correct 1 ms 208 KB OK (11 queries)
16 Correct 1 ms 208 KB OK (34 queries)
17 Correct 1 ms 208 KB OK (2 queries)
18 Correct 1 ms 208 KB OK (16 queries)
19 Correct 1 ms 208 KB OK (3 queries)
20 Correct 1 ms 208 KB OK (31 queries)
21 Correct 1 ms 208 KB OK (9 queries)
22 Correct 1 ms 208 KB OK (2 queries)
23 Correct 1 ms 208 KB OK (2 queries)
24 Correct 1 ms 208 KB OK (2 queries)
25 Correct 0 ms 208 KB OK (3 queries)
26 Correct 1 ms 208 KB OK (3 queries)
27 Correct 0 ms 208 KB OK (2 queries)
28 Correct 0 ms 208 KB OK (3 queries)
29 Correct 0 ms 208 KB OK (4 queries)
30 Correct 0 ms 284 KB OK (4 queries)
31 Correct 0 ms 208 KB OK (2 queries)
32 Correct 1 ms 208 KB OK (3 queries)
33 Correct 1 ms 208 KB OK (4 queries)
34 Correct 1 ms 208 KB OK (5 queries)
35 Correct 0 ms 208 KB OK (5 queries)
36 Correct 0 ms 208 KB OK (2 queries)
37 Correct 0 ms 208 KB OK (3 queries)
38 Correct 1 ms 208 KB OK (4 queries)
39 Correct 1 ms 208 KB OK (5 queries)
40 Correct 1 ms 208 KB OK (6 queries)
41 Correct 1 ms 208 KB OK (6 queries)
42 Correct 1 ms 208 KB OK (2 queries)
43 Correct 0 ms 208 KB OK (3 queries)
44 Correct 0 ms 208 KB OK (4 queries)
45 Correct 1 ms 208 KB OK (5 queries)
46 Correct 0 ms 208 KB OK (6 queries)
47 Correct 1 ms 332 KB OK (7 queries)
48 Correct 0 ms 208 KB OK (7 queries)
49 Correct 0 ms 208 KB OK (2 queries)
50 Correct 1 ms 208 KB OK (3 queries)
51 Correct 0 ms 208 KB OK (4 queries)
52 Correct 1 ms 208 KB OK (5 queries)
53 Correct 1 ms 212 KB OK (6 queries)
54 Correct 1 ms 208 KB OK (7 queries)
55 Correct 0 ms 208 KB OK (8 queries)
56 Correct 1 ms 208 KB OK (8 queries)
57 Correct 0 ms 208 KB OK (3 queries)
58 Correct 0 ms 208 KB OK (2 queries)
59 Correct 1 ms 208 KB OK (3 queries)
60 Correct 0 ms 208 KB OK (2 queries)
61 Correct 1 ms 208 KB OK (63 queries)
62 Correct 1 ms 208 KB OK (2 queries)
63 Correct 1 ms 208 KB OK (63 queries)
64 Correct 1 ms 208 KB OK (3 queries)
65 Correct 1 ms 208 KB OK (62 queries)
66 Correct 1 ms 208 KB OK (4 queries)
67 Correct 1 ms 308 KB OK (61 queries)
68 Correct 1 ms 208 KB OK (5 queries)
69 Correct 1 ms 208 KB OK (60 queries)
70 Correct 0 ms 208 KB OK (6 queries)
71 Correct 0 ms 208 KB OK (8 queries)
72 Runtime error 1 ms 208 KB Execution killed with signal 13
73 Halted 0 ms 0 KB -