Submission #750557

# Submission time Handle Problem Language Result Execution time Memory
750557 2023-05-29T17:25:34 Z vjudge1 Carnival (CEOI14_carnival) C++14
100 / 100
11 ms 208 KB
#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: warning: ignoring '#pragma warning ' [-Wunknown-pragmas]
   23 | #pragma warning(disable:4996)
      | 
carnival.cpp:24: warning: ignoring '#pragma comment ' [-Wunknown-pragmas]
   24 | #pragma comment(linker, "/STACK:336777216")
      | 
carnival.cpp: In function 'void aa(int, int)':
carnival.cpp:81:17: warning: unused variable 'j' [-Wunused-variable]
   81 |  int mx = 0, i, j;
      |                 ^
carnival.cpp: In function 'bool isValid(int, int, int)':
carnival.cpp:67:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   67 |  scanf("%d", &x);
      |  ~~~~~^~~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:109:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
  109 |  scanf("%d", &N);
      |  ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 208 KB Output is correct
2 Correct 9 ms 208 KB Output is correct
3 Correct 7 ms 208 KB Output is correct
4 Correct 7 ms 208 KB Output is correct
5 Correct 4 ms 208 KB Output is correct
6 Correct 2 ms 208 KB Output is correct
7 Correct 7 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 11 ms 208 KB Output is correct
3 Correct 6 ms 208 KB Output is correct
4 Correct 7 ms 208 KB Output is correct
5 Correct 4 ms 208 KB Output is correct
6 Correct 3 ms 208 KB Output is correct
7 Correct 9 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 208 KB Output is correct
2 Correct 3 ms 208 KB Output is correct
3 Correct 9 ms 208 KB Output is correct
4 Correct 4 ms 208 KB Output is correct
5 Correct 6 ms 208 KB Output is correct
6 Correct 4 ms 208 KB Output is correct
7 Correct 11 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 6 ms 208 KB Output is correct
3 Correct 9 ms 208 KB Output is correct
4 Correct 5 ms 208 KB Output is correct
5 Correct 4 ms 208 KB Output is correct
6 Correct 4 ms 208 KB Output is correct
7 Correct 8 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 9 ms 208 KB Output is correct
3 Correct 9 ms 208 KB Output is correct
4 Correct 9 ms 208 KB Output is correct
5 Correct 5 ms 208 KB Output is correct
6 Correct 5 ms 208 KB Output is correct
7 Correct 6 ms 208 KB Output is correct