Submission #107114

# Submission time Handle Problem Language Result Execution time Memory
107114 2019-04-22T04:23:13 Z LamoreauxAJ Carnival (CEOI14_carnival) C++14
100 / 100
11 ms 512 KB
#include <bits/stdc++.h>
using namespace std;

int N;

int main() {
    ios_base::sync_with_stdio(false);

    cin >> N;
    vector<vector<int>> sets;
    for (int i = 1; i <= N; i++) {
        if (sets.size() == 0)
            sets.push_back({i});
        else {
            cout << sets.size() + 1;
            for (auto v : sets)
                cout << " " << v[0];
            cout << " " << i;
            cout << endl;
            int res; cin >> res;
            if (res > sets.size())
                sets.push_back({i});
            else {
                int lo = 0, hi = sets.size() - 1;
                while (lo < hi) {
                    int m = (lo + hi) / 2;
                    cout << m - lo + 1 + 1;
                    for (int i = lo; i <= m; i++)
                        cout << " " << sets[i][0];
                    cout << " " << i;
                    cout << endl;
                    int res; cin >> res;
                    if (res == m - lo + 1)
                        hi = m;
                    else
                        lo = m + 1;
                }
                sets[lo].push_back(i);
            }
        }
    }

    vector<int> res(N);
    for (int i = 0; i < sets.size(); i++) {
        for (int v : sets[i])
            res[v - 1] = i + 1;
    }
    cout << "0";
    for (int i : res)
        cout << " " << i;
    cout << "\n";

    return 0;
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:21:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (res > sets.size())
                 ~~~~^~~~~~~~~~~~~
carnival.cpp:44:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < sets.size(); i++) {
                     ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 256 KB Output is correct
2 Correct 4 ms 340 KB Output is correct
3 Correct 6 ms 428 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 8 ms 256 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 3 ms 512 KB Output is correct
6 Correct 7 ms 256 KB Output is correct
7 Correct 8 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 7 ms 256 KB Output is correct
3 Correct 10 ms 256 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 4 ms 336 KB Output is correct
6 Correct 9 ms 384 KB Output is correct
7 Correct 10 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 336 KB Output is correct
2 Correct 5 ms 424 KB Output is correct
3 Correct 8 ms 384 KB Output is correct
4 Correct 6 ms 424 KB Output is correct
5 Correct 11 ms 256 KB Output is correct
6 Correct 7 ms 256 KB Output is correct
7 Correct 10 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 4 ms 336 KB Output is correct
3 Correct 7 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 6 ms 276 KB Output is correct
6 Correct 7 ms 384 KB Output is correct
7 Correct 5 ms 436 KB Output is correct