# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
995860 | cowwycow | Carnival (CEOI14_carnival) | C++14 | 2 ms | 344 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;
#define name "aaaaaa"
using ll = long long;
using pii = pair<ll, ll>;
void file(){
}
const int maxn = 155;
int ask(vector<int> a){
cout << a.size() << ' ';
for(int i : a){
cout << i << ' ';
}
cout << endl;
int x; cin >> x;
return x;
}
int ans[maxn];
vector<int> b;
void solve (){
int n; cin >> n;
ans[1] = 1;
b.push_back(1);
for(int i = 2; i <= n; i++){
vector<int> cur = b;
cur.push_back(i);
if(ask(cur) == cur.size() + 1){
b.push_back(i);
ans[i] = b.size();
}else{
int l = 0, r = b.size() - 1, mid, sus = -1;
while(l <= r){
mid = (l + r) / 2;
cur.clear();
for(int j = l; j <= mid; j++){
cur.push_back(b[j]);
}
cur.push_back(i);
if(ask(cur) == mid - l + 1){
sus = mid;
r = mid - 1;
}else{
l = mid + 1;
}
}
ans[i] = ans[b[sus]];
}
}
cout << 0 << ' ';
for(int i = 1; i <= n; i++){
cout << ans[i] << ' ';
}
}
int main(){
file();
solve();
}
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... |