답안 #74446

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
74446 2018-09-01T19:54:58 Z shoemakerjo 사육제 (CEOI14_carnival) C++14
100 / 100
10 ms 584 KB
#include <bits/stdc++.h>

using namespace std;
#define maxn 155

int N;

int ans[maxn];

vector<int> oq;

int query(vector<int> stuff, int val) {
	cout << stuff.size() + 1 << " ";
	for (int vv : stuff) cout << vv << " ";
	cout << val << endl;
	int ss ;
	cin >> ss;
	return ss;
}

int main() {
	cin >> N;
	ans[1] = 1;
	oq.push_back(1);
	for (int i = 2; i <= N; i++) {
		int cur = query(oq, i);
		if (cur == oq.size()+1) {
			ans[i] = oq.size()+1;
			oq.push_back(i);
			continue;
		}
		int l = 0;
		int r= oq.size()-1;
		while (l != r) {
			int mid = (l+r)/2;
			vector<int> vc;
			for (int i = l; i <= mid; i++) {
				vc.push_back(oq[i]);
			}
			int cans = query(vc, i); 
			if (cans == vc.size()) { //match is in here
				r = mid;
			}
			else {
				l = mid+1;
			}
		}
		// cout << i << " " <<  "l:  " << l << endl;
		ans[i] = ans[oq[l]];
	}

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

}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:27:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (cur == oq.size()+1) {
       ~~~~^~~~~~~~~~~~~~
carnival.cpp:41:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if (cans == vc.size()) { //match is in here
        ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 280 KB Output is correct
2 Correct 8 ms 328 KB Output is correct
3 Correct 5 ms 532 KB Output is correct
4 Correct 5 ms 532 KB Output is correct
5 Correct 3 ms 532 KB Output is correct
6 Correct 4 ms 532 KB Output is correct
7 Correct 6 ms 532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 532 KB Output is correct
2 Correct 10 ms 532 KB Output is correct
3 Correct 5 ms 536 KB Output is correct
4 Correct 4 ms 540 KB Output is correct
5 Correct 7 ms 552 KB Output is correct
6 Correct 7 ms 552 KB Output is correct
7 Correct 8 ms 552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 552 KB Output is correct
2 Correct 8 ms 552 KB Output is correct
3 Correct 6 ms 552 KB Output is correct
4 Correct 4 ms 552 KB Output is correct
5 Correct 7 ms 552 KB Output is correct
6 Correct 7 ms 552 KB Output is correct
7 Correct 5 ms 552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 552 KB Output is correct
2 Correct 6 ms 552 KB Output is correct
3 Correct 6 ms 552 KB Output is correct
4 Correct 5 ms 552 KB Output is correct
5 Correct 8 ms 552 KB Output is correct
6 Correct 7 ms 552 KB Output is correct
7 Correct 8 ms 552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 552 KB Output is correct
2 Correct 9 ms 552 KB Output is correct
3 Correct 5 ms 580 KB Output is correct
4 Correct 4 ms 584 KB Output is correct
5 Correct 7 ms 584 KB Output is correct
6 Correct 6 ms 584 KB Output is correct
7 Correct 4 ms 584 KB Output is correct