# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
531823 | christinelynn | Carnival (CEOI14_carnival) | C++17 | 19 ms | 320 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (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... |