Submission #140442

# Submission time Handle Problem Language Result Execution time Memory
140442 2019-08-03T01:14:55 Z silxikys Carnival (CEOI14_carnival) C++14
100 / 100
11 ms 424 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int maxn = 155;
int N; 
int ans[maxn];
vector<int> labels[maxn]; //indices of labels

int ask(vector<int>& v) {
    cout << v.size() << ' ';
    for (int i: v) cout << i << ' ';
    cout << endl;
    int res; cin >> res;
    return res;
}

int distinct[maxn];

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> N;
    ans[1] = 1;
    labels[1].push_back(1);
    int last = 1;
    for (int i = 1; i <= N; i++) {
        vector<int> v(i);
        iota(begin(v),end(v),1);
        distinct[i] = ask(v);
    }

    for (int i = 2; i <= N; i++) {
        int r1 = distinct[i-1];
        int r2 = distinct[i];
        if (r2 == r1+1) {
            ans[i] = ++last;
            labels[last].push_back(i);
        }
        else {
            //binary search for which one
            int lo = 1, hi = last;
            while (lo < hi) {
                int mid = (lo+hi)/2;
                vector<int> v;
                for (int j = 1; j <= mid; j++) {
                    v.push_back(labels[j][0]);
                }
                v.push_back(i);
                int r = ask(v);
                if (r == mid) {
                    hi = mid;
                }
                else {
                    lo = mid+1;
                }
            }
            ans[i] = lo;
            /*
            for (int i = 1; i <= last; i++) {
                vector<int> v = {labels[i][0],i};
                if (ask(v) == 1) {
                    ans[i] = i;
                }
            }
            */
        }
    }
    cout << 0 << ' ';
    for (int i = 1; i <= N; i++) {
        cout << ans[i] << ' ';
    }
    cout << endl;
}

# Verdict Execution time Memory Grader output
1 Correct 8 ms 248 KB Output is correct
2 Correct 9 ms 248 KB Output is correct
3 Correct 7 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 7 ms 248 KB Output is correct
6 Correct 6 ms 248 KB Output is correct
7 Correct 6 ms 248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 380 KB Output is correct
2 Correct 7 ms 248 KB Output is correct
3 Correct 6 ms 248 KB Output is correct
4 Correct 4 ms 332 KB Output is correct
5 Correct 7 ms 248 KB Output is correct
6 Correct 10 ms 376 KB Output is correct
7 Correct 9 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 248 KB Output is correct
2 Correct 9 ms 376 KB Output is correct
3 Correct 7 ms 376 KB Output is correct
4 Correct 5 ms 248 KB Output is correct
5 Correct 9 ms 248 KB Output is correct
6 Correct 6 ms 248 KB Output is correct
7 Correct 10 ms 248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 376 KB Output is correct
2 Correct 7 ms 248 KB Output is correct
3 Correct 8 ms 248 KB Output is correct
4 Correct 5 ms 248 KB Output is correct
5 Correct 6 ms 248 KB Output is correct
6 Correct 8 ms 424 KB Output is correct
7 Correct 7 ms 252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 248 KB Output is correct
2 Correct 11 ms 376 KB Output is correct
3 Correct 10 ms 376 KB Output is correct
4 Correct 9 ms 248 KB Output is correct
5 Correct 8 ms 248 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 6 ms 376 KB Output is correct