Submission #709085

# Submission time Handle Problem Language Result Execution time Memory
709085 2023-03-13T06:03:06 Z Shreyan_Paliwal Carnival (CEOI14_carnival) C++17
100 / 100
25 ms 208 KB
#include <bits/stdc++.h>
using namespace std;

int cnt = 2;
int id[150];

int qry(int l, int r) {
    cout << r - l + 1 << ' ';
    for (int i = l; i <= r; i++) cout << i << ' '; cout << endl;
    int x; cin >> x; return x;
}

void guess(int n) {
    cout << 0 << ' '; for (int i = 0; i < n; i++) cout << id[i] << ' '; cout << endl;
}


int main() {
    int n; cin >> n;
    id[0] = 1;

    int cval = qry(1, 1);

    for (int i = 1; i < n; i++) {
        int nval = qry(1, i+1);

        if (nval == cval + 1) {
            id[i] = cnt++;
        } else {
            // binary search on rightmost leftbound
            int lo = 0, hi = i - 1;
            while (lo < hi) {
                int mid = (lo + hi + 1) >> 1;
                // range [mid to i-1] & [mid to i] are same
                if (qry(mid+1, i) == qry(mid+1,i+1)) {
                    lo = mid;
                } else {
                    hi = mid-1;
                }
            }
            id[i] = id[lo];
        }

        cval = nval;
    }

    guess(n);

    return 0;
}

Compilation message

carnival.cpp: In function 'int qry(int, int)':
carnival.cpp:9:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
    9 |     for (int i = l; i <= r; i++) cout << i << ' '; cout << endl;
      |     ^~~
carnival.cpp:9:52: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
    9 |     for (int i = l; i <= r; i++) cout << i << ' '; cout << endl;
      |                                                    ^~~~
# Verdict Execution time Memory Grader output
1 Correct 19 ms 208 KB Output is correct
2 Correct 9 ms 208 KB Output is correct
3 Correct 9 ms 208 KB Output is correct
4 Correct 4 ms 208 KB Output is correct
5 Correct 18 ms 208 KB Output is correct
6 Correct 21 ms 208 KB Output is correct
7 Correct 18 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 208 KB Output is correct
2 Correct 19 ms 208 KB Output is correct
3 Correct 7 ms 208 KB Output is correct
4 Correct 7 ms 208 KB Output is correct
5 Correct 18 ms 208 KB Output is correct
6 Correct 16 ms 208 KB Output is correct
7 Correct 20 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 208 KB Output is correct
2 Correct 21 ms 208 KB Output is correct
3 Correct 17 ms 208 KB Output is correct
4 Correct 4 ms 208 KB Output is correct
5 Correct 17 ms 208 KB Output is correct
6 Correct 15 ms 208 KB Output is correct
7 Correct 20 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 208 KB Output is correct
2 Correct 25 ms 208 KB Output is correct
3 Correct 7 ms 208 KB Output is correct
4 Correct 2 ms 208 KB Output is correct
5 Correct 20 ms 208 KB Output is correct
6 Correct 13 ms 208 KB Output is correct
7 Correct 16 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 208 KB Output is correct
2 Correct 20 ms 208 KB Output is correct
3 Correct 14 ms 208 KB Output is correct
4 Correct 11 ms 208 KB Output is correct
5 Correct 10 ms 208 KB Output is correct
6 Correct 8 ms 208 KB Output is correct
7 Correct 5 ms 208 KB Output is correct