# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
531823 | christinelynn | Carnival (CEOI14_carnival) | C++17 | 19 ms | 320 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>>segments;
int color[152];
int ask(int x, int y){
cout << (y - x + 1) << " ";
for(int i = x; i <= y; i++) cout << i << " ";
cout << endl;
int ret; cin >> ret;
return ret;
}
int getSegment(int l, int r){
vector<bool>mark(152);
int cnt = 0;
for(int i = l; i <= r; i++){
if(!mark[color[i]]){
mark[color[i]] = true;
cnt++;
}
}
return cnt;
}
int main(){
int n; cin >> n;
int L = 1, R = 1;
for(int i = 1; i <= n; i++){
int tmp = 0;
if(i != n) tmp = ask(i, i + 1);
if(tmp == 1) R = i + 1;
else{
segments.emplace_back(L, R);
L = R = i + 1;
}
}
color[0] = 1;
color[1] = 2;
int lc = 2;
for(int i = 2; i < segments.size(); i++){
int l = 0, r = i - 1;
int col = lc + 1;
while(l <= r){
int m = (l + r)/2;
int cursegment = getSegment(m, i - 1) + 1;
int nahlo = ask(segments[m].first, segments[i].first);
if(cursegment > nahlo){
l = m + 1;
col = color[m];
} else{
r = m - 1;
}
}
if(col == lc + 1) lc++;
color[i] = col;
}
cout << "0 ";
for(int i = 0; i < segments.size(); i++){
auto &[l, r] = segments[i];
for(int j = l; j <= r; j++) cout << color[i] << " ";
}
cout << endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |