#include <bits/stdc++.h>
#define MP make_pair
#define F first
#define PB push_back
#define S second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int mod = (int)1e9 + 7;
const int maxn = 1e5 + 4;
const ll inf = 1e18;
int col = 1, c[maxn];
vector <int> v;
int print (int lo, int hi, bool wh) {
cout << hi - lo + wh << " ";
if (wh)
cout << v[0] << " ";
for (int i = lo; i < hi; i++)
cout << v[i] << " ";
cout << endl;
int k;
cin >> k;
return k;
}
void find_same (int lo, int hi) {
if (print (lo, hi, 1) > print (lo, hi, 0))
return;
if (lo + 1 == hi) {
c[v[lo]] = col;
return;
}
int mid = (hi + lo) >> 1;
find_same (lo, mid);
find_same (mid, hi);
}
int main (){
ios_base::sync_with_stdio(false);
int n;
cin >> n;
for (int i = 1; i <= n; i++)
v.PB (i);
while (!v.empty()) {
if (v.size() == 1) {
c[v.back()] = col;
break;
}
find_same (1, v.size());
c[v[0]] = col;
for (int i = 0; i < v.size(); i++)
if (c[v[i]] == col)
v.erase (v.begin() + i);
col ++;
}
cout << 0 << " ";
for (int i = 1; i <= n; i++)
cout << c[i] << " ";
cout << endl;
}
Compilation message
carnival.cpp: In function 'int main()':
carnival.cpp:53:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < v.size(); i++)
~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
20 ms |
376 KB |
Integer 12 violates the range [1, 11] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
13 ms |
456 KB |
Integer 6 violates the range [1, 5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
11 ms |
456 KB |
Integer 2 violates the range [1, 1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
15 ms |
580 KB |
Integer 5 violates the range [1, 4] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
580 KB |
Integer 3 violates the range [1, 2] |
2 |
Halted |
0 ms |
0 KB |
- |