Submission #308057

# Submission time Handle Problem Language Result Execution time Memory
308057 2020-09-30T02:06:24 Z updown1 Carnival (CEOI14_carnival) C++17
0 / 100
1 ms 256 KB
#include <bits/stdc++.h>
using namespace std;

const int maxv = 160;
vector<int> capMap(maxv);
int capColors[maxv];
 
 
bool check(int l, int r, int target) {
    cout << r - l + 2 << " ";
 
    cout << target << " ";
    for (int i = l; i <= r; i++) {
        cout << capMap[i] << " ";
    }
    cout << endl;
 
    int v;
    cin >> v;
    if (v > (r - l + 1)) {
        return true;
    }
    else {
        return false;
    }
}
 
int binary_search(int st, int en, int target) {
    int l = st;
    int r = en;
    while (l <= r) {
        int mid = (l + r)/2;
        if (! check(l, mid, target)) {
            r = mid - 1;
        }
        else {
            l = mid + 1;
        }
    }
    return l;
}
 
int main() {
    cin.tie(NULL);
 
    int N;
    cin >> N;
 
    // int currColors[N];
    int caps = 1;
 
    capColors[1] = 1;
    capMap[1] = 1;
 
    for(int i= 2; i< N + 1; i++) {
        cout << i << " " << i << " ";
        for (int j = 1; j <= caps; j++) {
            cout << capMap[j] << " ";
        }
        cout << endl;
        int amt;
        cin >> amt;
 
        if (amt > caps) {
            // need a new color
            caps++;
            capColors[i] = caps;
            capMap[caps] = i;
        }
        else {
            int id = binary_search(1, i - 1, i);
            capColors[i] = capMap[id];
        }
    }
 
    cout << "0 ";
    for(int i= 1; i< N + 1; i++) {
        cout << capColors[i] << " ";
    }
    cout << endl;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 0 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -