#include "bits/stdc++.h"
//#include "/Library/Developer/CommandLineTools/usr/include/c++/v1/bits/stdc++.h"
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0);
#define foru(j, a, b) for(int j = a; j <= b; ++j)
#define ford(j, a, b) for(int j = a; j >= b; --j)
#define mp make_pair
#define endl '\n'
#define ll long long
const int maxN = 1e5 + 5;
const int mod = 1e9 + 7;
const ll inf = 1e14;
vector<int> costume;
int ans[maxN];
signed main(){
IOS
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
int n, val;
cin >> n;
foru(i, 1, n){
bool check = true;
cout << costume.size() + 1 << " ";
for(int j = 0; j < costume.size(); j++) cout << costume[j] << " ";
cout << i << endl;
cout << flush;
cin >> val;
if(val == costume.size() + 1){
ans[i] = costume.size() + 1;
costume.push_back(i);
}
else{
int l = 0, r = costume.size() - 1;
while(l < r && check){
int mid = (l + r) >> 1;
cout << mid - l + 2 << " ";
for(int j = l; j <= mid; j++) cout << costume[j] << " ";
cout << i << endl;
cout << flush;
cin >> val;
if(val == 1){
ans[i] = ans[costume[l]];
break;
}
if(val == mid - l + 1){
r = mid;
}
else{
cout << r - mid + 1 << " ";
for(int j = mid + 1; j <= r; j++) cout << costume[j] << " ";
cout << i << endl;
cout << flush;
cin >> val;
if(val == 1){
ans[i] = ans[costume[mid + 1]];
break;
}
if(val == r - mid){
l = mid + 1;
}
}
}
}
}
cout << 0 << " ";
foru(j, 1, n) cout << ans[j] << " ";
}
Compilation message
carnival.cpp: In function 'int main()':
carnival.cpp:26:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
26 | for(int j = 0; j < costume.size(); j++) cout << costume[j] << " ";
| ~~^~~~~~~~~~~~~~~~
carnival.cpp:31:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | if(val == costume.size() + 1){
| ~~~~^~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
256 KB |
Output is correct |
2 |
Correct |
9 ms |
208 KB |
Output is correct |
3 |
Correct |
5 ms |
208 KB |
Output is correct |
4 |
Correct |
3 ms |
320 KB |
Output is correct |
5 |
Incorrect |
4 ms |
208 KB |
Integer 0 violates the range [1, 3] |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
208 KB |
Output is correct |
2 |
Correct |
9 ms |
208 KB |
Output is correct |
3 |
Correct |
5 ms |
208 KB |
Output is correct |
4 |
Correct |
7 ms |
208 KB |
Output is correct |
5 |
Correct |
8 ms |
208 KB |
Output is correct |
6 |
Incorrect |
5 ms |
208 KB |
Integer 0 violates the range [1, 15] |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
208 KB |
Integer 0 violates the range [1, 1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
208 KB |
Output is correct |
2 |
Correct |
7 ms |
208 KB |
Output is correct |
3 |
Correct |
7 ms |
208 KB |
Output is correct |
4 |
Correct |
4 ms |
208 KB |
Output is correct |
5 |
Correct |
9 ms |
208 KB |
Output is correct |
6 |
Correct |
7 ms |
208 KB |
Output is correct |
7 |
Correct |
10 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
208 KB |
Output is correct |
2 |
Correct |
9 ms |
220 KB |
Output is correct |
3 |
Correct |
7 ms |
208 KB |
Output is correct |
4 |
Correct |
8 ms |
208 KB |
Output is correct |
5 |
Correct |
7 ms |
208 KB |
Output is correct |
6 |
Correct |
6 ms |
208 KB |
Output is correct |
7 |
Correct |
4 ms |
208 KB |
Output is correct |