답안 #779802

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
779802 2023-07-11T21:43:49 Z NK_ 사육제 (CEOI14_carnival) C++17
100 / 100
19 ms 208 KB
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>

using namespace std;

#define nl '\n'

template<class T> using V = vector<T>;
int main() {
	cin.tie(0)->sync_with_stdio(0);
	
	int N; cin >> N;
	V<int> P(N, -1);

	auto ask = [&](int x, int l, int r) {
		cout << r - l + 1 << " ";
		for(int i = l; i <= r; i++) cout << " " << i + 1;
		cout << endl;

		int res1; cin >> res1; // WITHOUT

		cout << r - l + 1 + 1 << " " << x + 1;
		for(int i = l; i <= r; i++) cout << " " << i + 1;
		cout << endl;
	
		int res2; cin >> res2; // WITH

		return res1 == res2;
	};

	for(int i = 0; i < N; i++) {
		int lo = i, hi = N - 1;
		while(lo < hi) {
			int mid = (lo + hi + 1) / 2;
			// cout << lo << " " << mid << " " << hi << endl;
			if (ask(i, mid, hi)) lo = mid;
			else hi = mid - 1;
		}
		P[i] = lo;
	}	

	V<int> C(N, -1); int cur = 1;
	for(int i = N-1; i >= 0; i--) {
		// cout << i << " " << cur << endl;
		if (C[P[i]] == -1) C[i] = cur++;
		else C[i] = C[P[i]];
	}

	cout << 0;
	for(auto x : C) cout << " " << x;
	cout << endl;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 208 KB Output is correct
2 Correct 14 ms 208 KB Output is correct
3 Correct 14 ms 208 KB Output is correct
4 Correct 13 ms 208 KB Output is correct
5 Correct 9 ms 208 KB Output is correct
6 Correct 13 ms 208 KB Output is correct
7 Correct 10 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 208 KB Output is correct
2 Correct 16 ms 208 KB Output is correct
3 Correct 9 ms 208 KB Output is correct
4 Correct 8 ms 208 KB Output is correct
5 Correct 14 ms 208 KB Output is correct
6 Correct 15 ms 208 KB Output is correct
7 Correct 6 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 208 KB Output is correct
2 Correct 11 ms 208 KB Output is correct
3 Correct 15 ms 208 KB Output is correct
4 Correct 11 ms 208 KB Output is correct
5 Correct 17 ms 208 KB Output is correct
6 Correct 15 ms 208 KB Output is correct
7 Correct 17 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 208 KB Output is correct
2 Correct 13 ms 208 KB Output is correct
3 Correct 16 ms 208 KB Output is correct
4 Correct 14 ms 208 KB Output is correct
5 Correct 11 ms 208 KB Output is correct
6 Correct 10 ms 208 KB Output is correct
7 Correct 16 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 208 KB Output is correct
2 Correct 8 ms 208 KB Output is correct
3 Correct 16 ms 208 KB Output is correct
4 Correct 10 ms 208 KB Output is correct
5 Correct 15 ms 208 KB Output is correct
6 Correct 19 ms 208 KB Output is correct
7 Correct 12 ms 208 KB Output is correct