#include <bits/stdc++.h>
using namespace std;
long long i, j, l, r, mid, p, p2, q, k, t, n, m, a, b, c, d, cnt, ans[205];
vector <long long> arr;
const long long mod = 9999919999;
string s;
bool check;
long long query (vector <long long> a){
long long n = a.size();
cout << n << " ";
for (long long i = 0; i < n; i += 1){
cout << a[i] << " ";
}
cout << endl;
long long thl_bu_dau_sigma_top_1_doi_tuyen;
cin >> thl_bu_dau_sigma_top_1_doi_tuyen;
return thl_bu_dau_sigma_top_1_doi_tuyen;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
arr.push_back(1);
for (i = 2; i <= n; i += 1){
vector <long long> res = arr;
res.push_back(i);
if (query(res) == res.size()){
arr.push_back(i);
ans[i] = arr.size();
}
else{
l = 0;
r = arr.size() - 1;
p = 0;
while (l <= r){
mid = (l + r) >> 1;
res.clear();
for (j = l; j <= mid; j += 1){
res.push_back(arr[j]);
}
res.push_back(i);
if (query(res) == mid - l + 1){
p = arr[mid];
r = mid - 1;
}
else{
l = mid + 1;
}
}
ans[i] = ans[p];
}
}
cout << 0 << " " << 1 << " ";
for (i = 2; i <= n; i += 1){
cout << ans[i] << " ";
}
cout << endl;
}
Compilation message
carnival.cpp: In function 'int main()':
carnival.cpp:29:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | if (query(res) == res.size()){
| ~~~~~~~~~~~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
344 KB |
Integer 0 violates the range [1, 11] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
344 KB |
Integer 0 violates the range [1, 5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
344 KB |
Integer 0 violates the range [1, 1] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
344 KB |
Integer 0 violates the range [1, 4] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
344 KB |
Integer 0 violates the range [1, 2] |
2 |
Halted |
0 ms |
0 KB |
- |