#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
#define mp make_pair
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
#define ldb ldouble
typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
int ans[155];
int pos[155];
int pos2[155];
int ch[155];
bool isValid(int t, int s, int e) {
printf("%d ", e - s + 2);
printf("%d ", t);
for (int i = s; i <= e; i++) printf("%d ", pos[i]);
printf("\n");
fflush(stdout);
int x;
scanf("%d", &x);
return x == e - s + 1;
}
void aa(int st, int en) {
if (st == en) {
ans[st] = 1;
return;
}
int mi = (st + en) / 2;
aa(st, mi);
aa(mi + 1, en);
// printf("Merging %d~%d\n", st, en);
int mx = 0, i, j;
for (i = mi + 1; i <= en; i++) mx = max(mx, ans[i]);
for (i = mi + 1; i <= en; i++) pos[ans[i]] = i;
int mx2 = 0;
for (i = st; i <= mi; i++) mx2 = max(mx2, ans[i]);
for (i = st; i <= mi; i++) pos2[ans[i]] = i;
int n = mx;
for (i = 1; i <= mx2; i++) {
int p = pos2[i];
if (!isValid(p, 1, mx)) {
ch[i] = ++n;
continue;
}
int S = 1, E = mx, M;
while (S < E) {
M = (S + E) / 2;
if (isValid(p, S, M)) E = M;
else S = M + 1;
}
ch[i] = S;
}
for (i = st; i <= mi; i++) ans[i] = ch[ans[i]];
}
int main() {
int N, i;
scanf("%d", &N);
aa(1, N);
printf("0 ");
for (i = 1; i <= N; i++) printf("%d ", ans[i]);
printf("\n");
fflush(stdout);
return 0;
}
Compilation message
carnival.cpp:23:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
#pragma warning(disable:4996)
^
carnival.cpp:24:0: warning: ignoring #pragma comment [-Wunknown-pragmas]
#pragma comment(linker, "/STACK:336777216")
^
carnival.cpp: In function 'void aa(int, int)':
carnival.cpp:81:17: warning: unused variable 'j' [-Wunused-variable]
int mx = 0, i, j;
^
carnival.cpp: In function 'bool isValid(int, int, int)':
carnival.cpp:67:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &x);
^
carnival.cpp: In function 'int main()':
carnival.cpp:109:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &N);
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2020 KB |
Output is correct |
2 |
Correct |
3 ms |
2020 KB |
Output is correct |
3 |
Correct |
3 ms |
2020 KB |
Output is correct |
4 |
Correct |
3 ms |
2020 KB |
Output is correct |
5 |
Correct |
0 ms |
2020 KB |
Output is correct |
6 |
Correct |
0 ms |
2020 KB |
Output is correct |
7 |
Correct |
9 ms |
2020 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
2020 KB |
Output is correct |
2 |
Correct |
3 ms |
2020 KB |
Output is correct |
3 |
Correct |
0 ms |
2020 KB |
Output is correct |
4 |
Correct |
6 ms |
2020 KB |
Output is correct |
5 |
Correct |
3 ms |
2020 KB |
Output is correct |
6 |
Correct |
0 ms |
2020 KB |
Output is correct |
7 |
Correct |
0 ms |
2020 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2020 KB |
Output is correct |
2 |
Correct |
6 ms |
2020 KB |
Output is correct |
3 |
Correct |
9 ms |
2020 KB |
Output is correct |
4 |
Correct |
3 ms |
2020 KB |
Output is correct |
5 |
Correct |
3 ms |
2020 KB |
Output is correct |
6 |
Correct |
0 ms |
2020 KB |
Output is correct |
7 |
Correct |
3 ms |
2020 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
2020 KB |
Output is correct |
2 |
Correct |
0 ms |
2020 KB |
Output is correct |
3 |
Correct |
3 ms |
2020 KB |
Output is correct |
4 |
Correct |
6 ms |
2020 KB |
Output is correct |
5 |
Correct |
6 ms |
2020 KB |
Output is correct |
6 |
Correct |
9 ms |
2020 KB |
Output is correct |
7 |
Correct |
6 ms |
2020 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
2020 KB |
Output is correct |
2 |
Correct |
3 ms |
2020 KB |
Output is correct |
3 |
Correct |
0 ms |
2020 KB |
Output is correct |
4 |
Correct |
9 ms |
2020 KB |
Output is correct |
5 |
Correct |
3 ms |
2020 KB |
Output is correct |
6 |
Correct |
9 ms |
2020 KB |
Output is correct |
7 |
Correct |
3 ms |
2020 KB |
Output is correct |