Submission #777466

# Submission time Handle Problem Language Result Execution time Memory
777466 2023-07-09T09:19:22 Z MetalPower Carnival (CEOI14_carnival) C++14
100 / 100
11 ms 312 KB
#include <bits/stdc++.h>
using namespace std;

const int MX = 155;

int N, ans[MX];
vector<int> df;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> N;

	ans[1] = 1;
	df.push_back(1);

	int tim = 2;

	for(int i = 2; i <= N; i++){

		int l = 0, r = (int) df.size() - 1, memo = -1;

		for(; l <= r; ){
			int mid = l + r >> 1;

			vector<int> nw;
			for(int j = l; j <= mid; j++) nw.push_back(df[j]);
			nw.push_back(i);

			cout << nw.size();
			for(int x : nw) cout << " " << x;
			cout << endl;

			int num; cin >> num;

			if(num == (int) nw.size() - 1) memo = mid, r = mid - 1;
			else l = mid + 1;
		}

		if(memo == -1) ans[i] = tim++, df.push_back(i);
		else ans[i] = ans[df[memo]];
	}

	cout << 0;
	for(int i = 1; i <= N; i++) cout << " " << ans[i];
	cout << endl;
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:24:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   24 |    int mid = l + r >> 1;
      |              ~~^~~
# 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 8 ms 208 KB Output is correct
4 Correct 7 ms 296 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 5 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 5 ms 208 KB Output is correct
3 Correct 6 ms 208 KB Output is correct
4 Correct 8 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 5 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 4 ms 208 KB Output is correct
3 Correct 4 ms 208 KB Output is correct
4 Correct 6 ms 308 KB Output is correct
5 Correct 4 ms 208 KB Output is correct
6 Correct 5 ms 208 KB Output is correct
7 Correct 7 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 11 ms 208 KB Output is correct
4 Correct 8 ms 312 KB Output is correct
5 Correct 6 ms 208 KB Output is correct
6 Correct 5 ms 208 KB Output is correct
7 Correct 7 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 208 KB Output is correct
2 Correct 6 ms 208 KB Output is correct
3 Correct 8 ms 208 KB Output is correct
4 Correct 7 ms 208 KB Output is correct
5 Correct 8 ms 208 KB Output is correct
6 Correct 6 ms 208 KB Output is correct
7 Correct 9 ms 208 KB Output is correct