답안 #166679

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
166679 2019-12-03T13:02:47 Z alanhpereira 사육제 (CEOI14_carnival) C++11
100 / 100
19 ms 448 KB
#include <bits/stdc++.h>
#define MAX 160
using namespace std;

vector<int> lists[MAX];
int nlidx = 0;

int group[MAX];

int query(int l, int r, int e) {
	printf("%d ", r - l + 2);
	for (int i = l; i <= r; i++) {
		printf("%d ", lists[i][0]);
	}
	printf("%d\n", e);
	fflush(stdout);
	int ans;
	scanf("%d", &ans);
	return ans;
}

int main() {
	int n;
	scanf("%d", &n);
	group[1] = 1;
	lists[nlidx++].push_back(1);
	for (int i = 2; i <= n; i++) {
		int l = 0, r = nlidx - 1;
		int ans = query(l, r, i);
		if (ans == nlidx + 1) {
			lists[nlidx++].push_back(i);
			group[i] = nlidx;
			continue;
		}
		while (l != r) {
			int mid = (l + r) / 2;
			ans = query(l, mid, i);
			if (ans == mid - l + 2) {
				l = mid + 1;
			}
			else {
				r = mid;
			}
		}
		lists[l].push_back(i);
		group[i] = l + 1;
	}
	printf("0 ");
	for (int i = 1; i <= n; i++) {
		printf("%d ", group[i]);
	}
	printf("\n");
	return 0;
}

Compilation message

carnival.cpp: In function 'int query(int, int, int)':
carnival.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &ans);
  ~~~~~^~~~~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 376 KB Output is correct
2 Correct 10 ms 248 KB Output is correct
3 Correct 5 ms 448 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 248 KB Output is correct
6 Correct 3 ms 324 KB Output is correct
7 Correct 8 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 6 ms 316 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 316 KB Output is correct
6 Correct 7 ms 248 KB Output is correct
7 Correct 5 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 320 KB Output is correct
2 Correct 9 ms 380 KB Output is correct
3 Correct 10 ms 376 KB Output is correct
4 Correct 4 ms 400 KB Output is correct
5 Correct 5 ms 248 KB Output is correct
6 Correct 8 ms 376 KB Output is correct
7 Correct 10 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 248 KB Output is correct
2 Correct 8 ms 376 KB Output is correct
3 Correct 7 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 9 ms 376 KB Output is correct
6 Correct 9 ms 376 KB Output is correct
7 Correct 10 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 408 KB Output is correct
3 Correct 19 ms 376 KB Output is correct
4 Correct 11 ms 376 KB Output is correct
5 Correct 10 ms 248 KB Output is correct
6 Correct 7 ms 376 KB Output is correct
7 Correct 5 ms 400 KB Output is correct