#include "bits/stdc++.h"
using namespace std;
vector <int> v;
bool good(int pref, int x) {
cout << (pref + 1);
for(int i = 0; i < pref; i++) {
cout << ' ' << v[i];
}
cout << ' ' << x << endl;
int val;
cin >> val;
return (val == pref);
}
int search(int b, int e, int x) {
if(b == e) {
return b;
}
int m = (b + e) >> 1;
if(good(m, x)) return search(b, m, x);
else return search(m + 1, e, x);
}
int main(int argc, char const *argv[])
{
int n;
cin >> n;
v.push_back(1);
int now = 1;
for(int i = 2; i <= n; i++) {
v.push_back(i);
cout << v.size();
for(int j : v) {
cout << ' ' << j;
}
cout << endl;
int x;
cin >> x;
if(x > now) {
now = x;
} else {
v.pop_back();
}
}
bool vis[222];
int assign[222];
memset(assign, -1, sizeof assign);
memset(vis, false, sizeof vis);
for(int i = 1; i <= v.size(); i++) {
assign[v[i - 1]] = i;
vis[v[i - 1]] = true;
}
for(int i = 1; i <= n; i++) {
if(!vis[i]) {
assign[i] = search(1, v.size(), i);
}
}
cout << 0;
for(int i = 1; i <= n; i++) {
cout << ' ' << assign[i];
}
cout << endl;
return 0;
}
Compilation message
carnival.cpp: In function 'int main(int, const char**)':
carnival.cpp:50:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 1; i <= v.size(); i++) {
~~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
248 KB |
Output is correct |
2 |
Correct |
9 ms |
308 KB |
Output is correct |
3 |
Correct |
12 ms |
372 KB |
Output is correct |
4 |
Correct |
8 ms |
424 KB |
Output is correct |
5 |
Correct |
3 ms |
424 KB |
Output is correct |
6 |
Correct |
3 ms |
424 KB |
Output is correct |
7 |
Correct |
13 ms |
424 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
424 KB |
Output is correct |
2 |
Correct |
8 ms |
424 KB |
Output is correct |
3 |
Correct |
7 ms |
424 KB |
Output is correct |
4 |
Correct |
4 ms |
460 KB |
Output is correct |
5 |
Correct |
12 ms |
460 KB |
Output is correct |
6 |
Correct |
9 ms |
460 KB |
Output is correct |
7 |
Correct |
11 ms |
480 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
480 KB |
Output is correct |
2 |
Correct |
6 ms |
480 KB |
Output is correct |
3 |
Correct |
10 ms |
480 KB |
Output is correct |
4 |
Correct |
6 ms |
512 KB |
Output is correct |
5 |
Correct |
8 ms |
524 KB |
Output is correct |
6 |
Correct |
9 ms |
524 KB |
Output is correct |
7 |
Correct |
11 ms |
524 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
524 KB |
Output is correct |
2 |
Correct |
5 ms |
524 KB |
Output is correct |
3 |
Correct |
7 ms |
524 KB |
Output is correct |
4 |
Correct |
8 ms |
564 KB |
Output is correct |
5 |
Correct |
12 ms |
564 KB |
Output is correct |
6 |
Correct |
6 ms |
564 KB |
Output is correct |
7 |
Correct |
11 ms |
564 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
564 KB |
Output is correct |
2 |
Correct |
6 ms |
564 KB |
Output is correct |
3 |
Correct |
9 ms |
564 KB |
Output is correct |
4 |
Correct |
8 ms |
564 KB |
Output is correct |
5 |
Correct |
10 ms |
564 KB |
Output is correct |
6 |
Correct |
4 ms |
564 KB |
Output is correct |
7 |
Correct |
6 ms |
564 KB |
Output is correct |