답안 #995914

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
995914 2024-06-10T03:53:18 Z BuzzyBeez 사육제 (CEOI14_carnival) C++17
0 / 100
2 ms 600 KB
#include <bits/stdc++.h>
using namespace std;

int n, res;
set<int> rem;
int a[200];

vector<int> Q;
int ask(int l, int lim) {
	Q.clear();
	for (int i = l; i <= lim; ++i) if (!a[i]) Q.push_back(i);
	// assert(Q.size());
	cout << Q.size() << ' ';
	for (int i : Q) cout << i << ' ';
	cout << endl;
	cin >> res; return res;
}

void answer() {
	cout << 0 << ' ';
	for (int i = 1; i <= n; ++i) cout << a[i] << ' ';
	cout << endl;
}

signed main() {
	cin >> n; int l, r, mid, pt, num = 1, m;
	for (int i = 1; i <= n; ++i) rem.insert(i);
	while (rem.size()) {
		pt = 0; m = *prev(rem.end());
		// cout << "Remaining : ";
		// for (int i : rem) cout << i << ' ';
		// cout << endl;
		if (ask(1, m) == 1) {
			for (int i : rem) a[i] = num;
			break;
		}
		while (ask(1, m - 1) == ask(1, m) && pt < m) {
			l = pt + 1; r = m - 1;
			while (l <= r) {
				mid = (l + r) / 2;
				// assert(mid < m);
				if (ask(mid, m - 1) == ask(mid, m)) l = mid + 1;
				else r = mid - 1;
			}
			pt = l - 1;
			while (a[pt]) ++pt;
			assert(!a[pt] && pt < m);
			a[pt] = num; 
			// assert(rem.find(pt) != rem.end());
			rem.erase(pt);
			// cout << "found " << pt << " : " << a[pt] << "!!" << endl;
		}
		a[m] = num; rem.erase(m);
		++num;
	}
	answer();
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 596 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Runtime error 1 ms 600 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -