Submission #469255

# Submission time Handle Problem Language Result Execution time Memory
469255 2021-08-31T09:17:20 Z Valaki2 Carnival (CEOI14_carnival) C++14
100 / 100
30 ms 200 KB
#include <bits/stdc++.h>
using namespace std;

int query1(int l, int r, int cur) {
    cout << r - l + 2 << " ";
    for(int i = l; i <= r; ++i) cout << i << " ";
    cout << cur << endl;
    int res;
    cin >> res;
    return res;
}

int query2(int l, int r) {
    cout << r - l + 1 << " ";
    for(int i = l; i <= r; ++i) cout << i << " ";
    cout << endl;
    int res;
    cin >> res;
    return res;
}

void solve() {
    int n;
    cin >> n;
    vector<int> ans(1 + n, 0);
    vector<int> prefDiffNum(1 + n, 0);
    for(int i = 1; i <= n; ++i) {
        prefDiffNum[i] = query2(1, i);
    }
    int curCnt = 0;
    for(int i = 1; i <= n; ++i) {
        if(prefDiffNum[i] != prefDiffNum[i - 1]) {
            ++curCnt;
            ans[i] = curCnt;
        } else {
            int l = 1, r = i;
            while(l < r - 1) {
                int mid = (l + r) / 2;
                int a = query1(mid, r - 1, i);
                int b = query2(mid, r - 1);
                if(a == b) {
                    l = mid;
                } else {
                    r = mid;
                }
            }
            ans[i] = ans[l];
        }
    }
    cout << "0 ";
    for(int i = 1; i <= n; ++i) cout << ans[i] << " ";
    cout << endl;
}

int main() {
    solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 23 ms 200 KB Output is correct
2 Correct 20 ms 200 KB Output is correct
3 Correct 9 ms 200 KB Output is correct
4 Correct 5 ms 200 KB Output is correct
5 Correct 24 ms 200 KB Output is correct
6 Correct 16 ms 200 KB Output is correct
7 Correct 17 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 200 KB Output is correct
2 Correct 19 ms 200 KB Output is correct
3 Correct 7 ms 200 KB Output is correct
4 Correct 5 ms 200 KB Output is correct
5 Correct 30 ms 200 KB Output is correct
6 Correct 29 ms 200 KB Output is correct
7 Correct 23 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 200 KB Output is correct
2 Correct 25 ms 200 KB Output is correct
3 Correct 17 ms 200 KB Output is correct
4 Correct 4 ms 200 KB Output is correct
5 Correct 22 ms 200 KB Output is correct
6 Correct 24 ms 200 KB Output is correct
7 Correct 15 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 200 KB Output is correct
2 Correct 27 ms 200 KB Output is correct
3 Correct 7 ms 200 KB Output is correct
4 Correct 4 ms 200 KB Output is correct
5 Correct 20 ms 200 KB Output is correct
6 Correct 14 ms 200 KB Output is correct
7 Correct 18 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 200 KB Output is correct
2 Correct 26 ms 200 KB Output is correct
3 Correct 10 ms 200 KB Output is correct
4 Correct 13 ms 200 KB Output is correct
5 Correct 14 ms 200 KB Output is correct
6 Correct 11 ms 200 KB Output is correct
7 Correct 4 ms 200 KB Output is correct