Submission #73793

# Submission time Handle Problem Language Result Execution time Memory
73793 2018-08-29T04:04:49 Z arman_ferdous Carnival (CEOI14_carnival) C++17
100 / 100
35 ms 824 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 155;
int n, ans[N], dp[N][N];

int ask(int l, int r) {
	if(dp[l][r]) return dp[l][r];
	if(l == r) return 1;

	cout << r - l + 1;
	for(int i = l; i <= r; i++)
		cout << " " << i;
	cout << endl;
	int ret; cin >> ret;
	return dp[l][r] = ret;
}

int main() {
	cin >> n;
	fill(ans+1,ans+n+1,-1);
	int cur = 1;
	for(int i = 1; i <= n; i++) {
		if(ans[i] == -1) ans[i] = cur++;
		int lo = i+1, hi = n, idx = i;
		while(lo <= hi) {
			int mid = (lo + hi) >> 1;
			if(ask(i,mid) != ask(i+1,mid)) 
				idx = mid, lo = mid+1;
			else hi = mid-1;
		} ans[idx+1] = ans[i];
	}
	cout << "0";
	for(int i = 1; i <= n; i++) 
		cout << " " << ans[i];
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 17 ms 296 KB Output is correct
2 Correct 20 ms 476 KB Output is correct
3 Correct 20 ms 524 KB Output is correct
4 Correct 22 ms 524 KB Output is correct
5 Correct 27 ms 616 KB Output is correct
6 Correct 20 ms 616 KB Output is correct
7 Correct 14 ms 616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 824 KB Output is correct
2 Correct 20 ms 824 KB Output is correct
3 Correct 14 ms 824 KB Output is correct
4 Correct 21 ms 824 KB Output is correct
5 Correct 20 ms 824 KB Output is correct
6 Correct 19 ms 824 KB Output is correct
7 Correct 12 ms 824 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 824 KB Output is correct
2 Correct 18 ms 824 KB Output is correct
3 Correct 13 ms 824 KB Output is correct
4 Correct 14 ms 824 KB Output is correct
5 Correct 23 ms 824 KB Output is correct
6 Correct 17 ms 824 KB Output is correct
7 Correct 21 ms 824 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 824 KB Output is correct
2 Correct 19 ms 824 KB Output is correct
3 Correct 35 ms 824 KB Output is correct
4 Correct 24 ms 824 KB Output is correct
5 Correct 22 ms 824 KB Output is correct
6 Correct 28 ms 824 KB Output is correct
7 Correct 24 ms 824 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 824 KB Output is correct
2 Correct 32 ms 824 KB Output is correct
3 Correct 30 ms 824 KB Output is correct
4 Correct 16 ms 824 KB Output is correct
5 Correct 14 ms 824 KB Output is correct
6 Correct 34 ms 824 KB Output is correct
7 Correct 15 ms 824 KB Output is correct