답안 #114469

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
114469 2019-06-01T12:21:01 Z 김세빈(#2861) 사육제 (CEOI14_carnival) C++14
100 / 100
20 ms 440 KB
#include <bits/stdc++.h>

using namespace std;

int D[222], C[222];
int n, k;

int query(vector <int> &Q)
{
	int v;
	
	printf("%d", Q.size());
	for(int &t: Q) printf(" %d", t);
	printf("\n"); fflush(stdout);
	
	scanf("%d", &v);
	
	return v;
}

int main()
{
	vector <int> Q;
	int i, j, s, e, m;
	
	scanf("%d", &n);
	
	for(i=1; i<=n; i++){
		Q.clear();
		for(j=1; j<=i; j++){
			Q.push_back(j);
		}
		D[i] = query(Q);
		
		for(s=1, e=i-1; s<=e; ){
			m = s + e >> 1;
			Q.clear();
			for(j=1; j<=m; j++){
				Q.push_back(j);
			}
			Q.push_back(i);
			
			if(query(Q) == D[m]) e = m - 1;
			else s = m + 1;
		}
		
		if(e + 1 == i) C[i] = ++k;
		else C[i] = C[e + 1];
	}
	
	printf("0");
	
	for(i=1; i<=n; i++){
		printf(" %d", C[i]);
	}
	
	printf("\n"); fflush(stdout);
	
	return 0;
}

Compilation message

carnival.cpp: In function 'int query(std::vector<int>&)':
carnival.cpp:12:23: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
  printf("%d", Q.size());
               ~~~~~~~~^
carnival.cpp: In function 'int main()':
carnival.cpp:36:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    m = s + e >> 1;
        ~~^~~
carnival.cpp: In function 'int query(std::vector<int>&)':
carnival.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &v);
  ~~~~~^~~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:26: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 10 ms 256 KB Output is correct
2 Correct 7 ms 324 KB Output is correct
3 Correct 8 ms 320 KB Output is correct
4 Correct 9 ms 316 KB Output is correct
5 Correct 12 ms 440 KB Output is correct
6 Correct 12 ms 256 KB Output is correct
7 Correct 11 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 312 KB Output is correct
2 Correct 12 ms 376 KB Output is correct
3 Correct 7 ms 256 KB Output is correct
4 Correct 13 ms 400 KB Output is correct
5 Correct 9 ms 256 KB Output is correct
6 Correct 10 ms 384 KB Output is correct
7 Correct 7 ms 408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 256 KB Output is correct
2 Correct 13 ms 376 KB Output is correct
3 Correct 20 ms 380 KB Output is correct
4 Correct 19 ms 256 KB Output is correct
5 Correct 12 ms 384 KB Output is correct
6 Correct 15 ms 256 KB Output is correct
7 Correct 12 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 320 KB Output is correct
2 Correct 12 ms 312 KB Output is correct
3 Correct 16 ms 256 KB Output is correct
4 Correct 20 ms 256 KB Output is correct
5 Correct 8 ms 328 KB Output is correct
6 Correct 12 ms 384 KB Output is correct
7 Correct 16 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 412 KB Output is correct
2 Correct 9 ms 256 KB Output is correct
3 Correct 17 ms 256 KB Output is correct
4 Correct 10 ms 400 KB Output is correct
5 Correct 12 ms 256 KB Output is correct
6 Correct 11 ms 324 KB Output is correct
7 Correct 18 ms 256 KB Output is correct