Submission #757285

# Submission time Handle Problem Language Result Execution time Memory
757285 2023-06-13T01:46:38 Z yash_9a3b Carnival (CEOI14_carnival) C++17
100 / 100
9 ms 300 KB
#include <iostream>
#include <vector>
using namespace std;
 
int n;
vector<int> rep, c;
 
int query(int l, int r) {
    cout << r - l + 1 << ' ';
    for (int i = l; i <= r; i++) {
        cout << rep[i] << ' ';
    }
    cout << endl;
    int ret;
    cin >> ret;
    return ret;
}
 
int twin() {
    int lo = 0, hi = rep.size() - 1;
    while (hi - lo > 1) {
        int mid = (hi + lo) / 2;
        if (query(mid, rep.size() - 1) < rep.size() - mid) lo = mid;
        else hi = mid - 1;
    }
    if (query(hi, rep.size() - 1) < rep.size() - hi) return hi;
    return lo;
}
 
int main() {
    cin >> n;
    c.resize(n + 1);
    for (int i = 1; i <= n; i++) {
        rep.push_back(i);
        if (query(0, rep.size() - 1) == rep.size()) {
            c[i] = rep.size();
            continue;
        }
        c[i] = c[rep[twin()]];
        rep.pop_back();
    }
    cout << 0 << ' ';
    for (int i = 1; i <= n; i++) {
        cout << c[i] << ' ';
    }
    cout << endl;
    return 0;
}

Compilation message

carnival.cpp: In function 'int twin()':
carnival.cpp:23:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |         if (query(mid, rep.size() - 1) < rep.size() - mid) lo = mid;
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
carnival.cpp:26:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     if (query(hi, rep.size() - 1) < rep.size() - hi) return hi;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:35:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         if (query(0, rep.size() - 1) == rep.size()) {
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 208 KB Output is correct
2 Correct 8 ms 208 KB Output is correct
3 Correct 5 ms 208 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
5 Correct 2 ms 208 KB Output is correct
6 Correct 5 ms 208 KB Output is correct
7 Correct 9 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 208 KB Output is correct
2 Correct 8 ms 208 KB Output is correct
3 Correct 5 ms 208 KB Output is correct
4 Correct 4 ms 208 KB Output is correct
5 Correct 5 ms 208 KB Output is correct
6 Correct 6 ms 208 KB Output is correct
7 Correct 7 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 208 KB Output is correct
2 Correct 5 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 7 ms 208 KB Output is correct
6 Correct 3 ms 208 KB Output is correct
7 Correct 9 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 208 KB Output is correct
2 Correct 7 ms 208 KB Output is correct
3 Correct 5 ms 208 KB Output is correct
4 Correct 3 ms 300 KB Output is correct
5 Correct 6 ms 208 KB Output is correct
6 Correct 7 ms 208 KB Output is correct
7 Correct 9 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 7 ms 208 KB Output is correct
3 Correct 9 ms 208 KB Output is correct
4 Correct 6 ms 208 KB Output is correct
5 Correct 7 ms 208 KB Output is correct
6 Correct 6 ms 208 KB Output is correct
7 Correct 3 ms 208 KB Output is correct