#include <bits/stdc++.h>
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vll vector<ll>
#define all(v) v.begin(), v.end()
#define whole(a) a+1, a+1+n
#define OPT ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define sec second
#define fi first
#define print(k) cerr << "Ans : "; cout << k << endl;
#define ins insert
#define pb push_back
#define bpc __builtin_popcountll
#define skip continue
#define endll '\n'
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) a*b / (__gcd(a, b))
#define mpr make_pair
#define rep(i,l,r) for(ll i=l;i<=r;++i)
#define new '\n'
typedef long long ll;
typedef unsigned long long ull;
const int mod = 998244353;
const int sz = 3e5+5;
using namespace std;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int c[150];
int p[150];
main(){
OPT
int n;
cin >> n;
c[1] = 1;
p[1] = 1;
int k = 1;
for (int i = 2; i <= n; ++i)
{
cout << k + 1 << ' ';
for(int j = 1; j <= k; ++j){
cout << p[j] << ' ';
}
cout << i << endl;
int res = 0;
cin >> res;
if( res == k + 1)
{
c[i] = ++k;
p[k] = i;
continue;
}
int l = 1;
int r = k;
while ( l < r )
{
int mid = (l + r) >> 1;
cout << mid + 1 << ' ';
for ( int j = 1; j <= mid; ++j)
{
cout << p[j] << ' ';
}
cout << i << endl;
int res;
cin >> res;
if( res == mid + 1)
{
l = mid + 1;
}
else{
r = mid;
}
}
p[l] = i;
c[i] = l;
}
cout << 0 << ' ';
for ( int i = 1; i <= n; ++i)
{
cout << c[i] << ' ';
}
cout << endl;
}
Compilation message
carnival.cpp:33:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
33 | main(){
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
344 KB |
Output is correct |
2 |
Correct |
3 ms |
344 KB |
Output is correct |
3 |
Correct |
2 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
3 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
5 ms |
344 KB |
Output is correct |
3 |
Correct |
2 ms |
344 KB |
Output is correct |
4 |
Correct |
2 ms |
344 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
3 ms |
344 KB |
Output is correct |
7 |
Correct |
2 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
344 KB |
Output is correct |
3 |
Correct |
4 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
344 KB |
Output is correct |
5 |
Correct |
4 ms |
416 KB |
Output is correct |
6 |
Correct |
2 ms |
344 KB |
Output is correct |
7 |
Correct |
3 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
344 KB |
Output is correct |
3 |
Correct |
2 ms |
344 KB |
Output is correct |
4 |
Correct |
2 ms |
344 KB |
Output is correct |
5 |
Correct |
3 ms |
344 KB |
Output is correct |
6 |
Correct |
3 ms |
344 KB |
Output is correct |
7 |
Correct |
3 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
3 ms |
344 KB |
Output is correct |
3 |
Correct |
3 ms |
344 KB |
Output is correct |
4 |
Correct |
3 ms |
344 KB |
Output is correct |
5 |
Correct |
3 ms |
344 KB |
Output is correct |
6 |
Correct |
2 ms |
344 KB |
Output is correct |
7 |
Correct |
2 ms |
344 KB |
Output is correct |