# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
433171 | apotosaurus | 사육제 (CEOI14_carnival) | C++11 | 9 ms | 296 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define DEBUG false
#define cdbg if (!DEBUG) {} else cerr
// #define int long long
// #define INFILE "carnival.in"
// #define OUTFILE "carnival.out"
int N;
vector<int> reps;
vector<int> unassigned;
vector<int> res;
int curCostume = 0;
void readInput(){
cin >> N;
res.resize(N);
}
//checks if the closed interval [0,x] has reps[i] = it for some i in the interval
bool works (int x, int it){
cout << x+2 << " ";
for (int i = 0; i <= x; i++){
cout << reps[i] << " ";
}
cout << it << endl;
int tmp;
cin >> tmp;
cdbg << "\tWorks: " << (tmp == x+1) << endl;
return (tmp == x+1);
}
//looking for the smallest x such that for all 0<=i<=x, reps[i] = it
int search(int it){
int lb = 0;
int ub = reps.size()-1;
//lb is largest such that nothing below it inclusive contains it
//ub is the smallest such that something below it inclusive contains it
while (lb < ub){
int mid = (lb + ub) / 2;
if (works(mid, it)){
ub = mid;
}
else{
lb = mid + 1;
}
}
cdbg << lb << endl;
return lb;
}
void solve(){
reps.push_back(1);
res[0] = reps.size();
for (int i = 1; i < N; i++){
cout << (reps.size() + 1) << " ";
for (int j = 0; j < reps.size(); j++){
cout << reps[j] << " ";
}
cout << i+1 << endl;
int tmp;
cin >> tmp;
if (tmp == reps.size()){
unassigned.push_back(i+1);
}
else{
reps.push_back(i+1);
res[i] = reps.size();
}
}
//binary search now
for (auto it:unassigned){
res[it-1] = res[search(it)];
}
cout << 0 << " ";
for (int i = 0; i < N; i++){
cout << res[i] << " ";
}
cout << endl;
}
// main(){
int main(){
// freopen(INFILE, "r", stdin); // redirects standard input
// freopen(OUTFILE, "w", stdout); // redirects standard output
readInput();
solve();
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... |