/*
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
*/
// lethal option
#include<bits/stdc++.h>
using namespace std;
#define all(flg) flg.begin(), flg.end()
#define int long long
#define pb push_back
#define fi first
#define se second
#define eb emplace_back
#define ii pair<int, int>
#define vi vector<int>
#define PI 3.141592653589793238462643383279502884
#define ll long long
#define ld long double
#define for1(i, ff, gg) for(int i = ff; i <= gg; ++i)
#define for2(i, ff, gg) for(int i = ff; i >= gg; --i)
const ll mod = 1e9 + 7;
const int maxN = 155;
const ll oo = 1e18 + 7;
int n, a[maxN];
int x, y, z, k;
int ans[maxN];
int isdif(vi sus){
cout << sus.size() << endl;
for(int cc : sus) cout << cc << " ";
cout << endl;
int x; cin >> x; return(x != sus.size());
}
void sliced(vi &v, vi &v1, vi &v2){
v1.clear();
v2.clear();
for1(i, 0, (int)v.size() - 1){
if(i & 1) v1.pb(v[i]);
else v2.pb(v[i]);
}
}
vi cope(vi f1, vi f2){
for(int cc : f2) f1.pb(cc);
return f1;
}
void solve(vi cac){
vi store = cac;
if(!isdif(cac)){
x = 0;
for(int cc : cac) ans[cc] = ++x;
return;
}
vi f1, f2;
while(1){
sliced(cac, f1, f2);
if(isdif(f1)) cac = f1;
else if(isdif(f2)) cac = f2;
else break;
}
while(1){
if(f1.size() == 1) swap(f1, f2);
if(f1.size() == 1) break;
vi c1, c2;
sliced(f1, c1, c2);
if(isdif(cope(c1, f2))) f1 = c1;
else f1 = c2;
}
ans[f1[0]] = -f2[0];
vi good;
for(int cc : store) if(cc != f1[0]) good.pb(cc);
solve(good);
}
signed main(){
// freopen(".inp", "r", stdin);
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
cin >> n;
vi cac;
memset(ans, 0, sizeof(ans));
for1(i, 1, n) cac.pb(i);
solve(cac);
cout << 0 << endl;
for1(i, 1, n){
for1(i, 1, n){
if(ans[i] < 0) ans[i] = ans[-ans[i]];
}
}
for1(i, 1, n) cout << ans[i] << " ";
cout << endl;
}
Compilation message
carnival.cpp: In function 'long long int isdif(std::vector<long long int>)':
carnival.cpp:36:31: 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]
36 | int x; cin >> x; return(x != sus.size());
| ~~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
652 KB |
Output is correct |
2 |
Correct |
8 ms |
588 KB |
Output is correct |
3 |
Correct |
7 ms |
464 KB |
Output is correct |
4 |
Correct |
2 ms |
352 KB |
Output is correct |
5 |
Correct |
13 ms |
608 KB |
Output is correct |
6 |
Correct |
11 ms |
712 KB |
Output is correct |
7 |
Correct |
12 ms |
680 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
764 KB |
Output is correct |
2 |
Correct |
16 ms |
756 KB |
Output is correct |
3 |
Correct |
4 ms |
356 KB |
Output is correct |
4 |
Correct |
4 ms |
336 KB |
Output is correct |
5 |
Correct |
19 ms |
732 KB |
Output is correct |
6 |
Correct |
17 ms |
660 KB |
Output is correct |
7 |
Correct |
16 ms |
700 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
684 KB |
Output is correct |
2 |
Correct |
10 ms |
716 KB |
Output is correct |
3 |
Correct |
22 ms |
596 KB |
Output is correct |
4 |
Correct |
2 ms |
336 KB |
Output is correct |
5 |
Correct |
23 ms |
752 KB |
Output is correct |
6 |
Correct |
15 ms |
752 KB |
Output is correct |
7 |
Correct |
13 ms |
740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
660 KB |
Output is correct |
2 |
Correct |
14 ms |
712 KB |
Output is correct |
3 |
Correct |
5 ms |
444 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
12 ms |
744 KB |
Output is correct |
6 |
Correct |
9 ms |
656 KB |
Output is correct |
7 |
Correct |
22 ms |
716 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
720 KB |
Output is correct |
2 |
Correct |
18 ms |
692 KB |
Output is correct |
3 |
Correct |
10 ms |
512 KB |
Output is correct |
4 |
Correct |
5 ms |
584 KB |
Output is correct |
5 |
Correct |
5 ms |
656 KB |
Output is correct |
6 |
Correct |
7 ms |
464 KB |
Output is correct |
7 |
Correct |
2 ms |
336 KB |
Output is correct |