답안 #108108

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
108108 2019-04-27T13:07:20 Z tjd229 사육제 (CEOI14_carnival) C++14
100 / 100
27 ms 412 KB
#include <stdio.h>
int N;
int c[151];
int ask(int s,int e,int piv=0) {
	int len = e - s + 1 + (piv > 0);
	if (len == 1) return 1;
	printf("%d ",len);
	for (int i = s; i <= e; ++i) printf("%d ",i);
	if (piv) printf("%d ",piv);
	printf("\n"); fflush(stdout);
	int diff; scanf("%d",&diff);
	return diff;
}
int find(int piv,int s,int e) {
	if (s == e) return s;
	int m = (s + e) >> 1;
	if (ask(s, m, piv) == ask(s, m))
		return find(piv,s,m);
	return find(piv, m + 1, e);
}
int main() {
	int i, cnt = 0;
	for (scanf("%d",&N),i = 1; i < N; ++i) {
		if (!c[i]) c[i]=++cnt;
		if (ask(i, N) == ask(i + 1, N)) {
			int r = find(i,i+1,N);
			c[r] = c[i];
		}
	}
	if (!c[i]) c[i] = ++cnt;
	for (printf("0 "), i = 1; i <= N; ++i) printf("%d ",c[i]);
	fflush(stdout);
	return 0;
}

Compilation message

carnival.cpp: In function 'int ask(int, int, int)':
carnival.cpp:11:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int diff; scanf("%d",&diff);
            ~~~~~^~~~~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:23:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (scanf("%d",&N),i = 1; i < N; ++i) {
       ~~~~~~~~~~~~~~^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 384 KB Output is correct
2 Correct 15 ms 256 KB Output is correct
3 Correct 9 ms 384 KB Output is correct
4 Correct 9 ms 412 KB Output is correct
5 Correct 14 ms 384 KB Output is correct
6 Correct 10 ms 284 KB Output is correct
7 Correct 19 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 256 KB Output is correct
2 Correct 23 ms 384 KB Output is correct
3 Correct 8 ms 384 KB Output is correct
4 Correct 8 ms 256 KB Output is correct
5 Correct 17 ms 256 KB Output is correct
6 Correct 21 ms 256 KB Output is correct
7 Correct 16 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 300 KB Output is correct
2 Correct 20 ms 384 KB Output is correct
3 Correct 19 ms 384 KB Output is correct
4 Correct 9 ms 384 KB Output is correct
5 Correct 22 ms 256 KB Output is correct
6 Correct 17 ms 384 KB Output is correct
7 Correct 19 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 384 KB Output is correct
2 Correct 24 ms 256 KB Output is correct
3 Correct 13 ms 256 KB Output is correct
4 Correct 9 ms 256 KB Output is correct
5 Correct 16 ms 256 KB Output is correct
6 Correct 12 ms 256 KB Output is correct
7 Correct 12 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 384 KB Output is correct
2 Correct 19 ms 384 KB Output is correct
3 Correct 10 ms 284 KB Output is correct
4 Correct 11 ms 256 KB Output is correct
5 Correct 11 ms 252 KB Output is correct
6 Correct 12 ms 256 KB Output is correct
7 Correct 7 ms 384 KB Output is correct