답안 #347277

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
347277 2021-01-12T13:34:54 Z maomao90 사육제 (CEOI14_carnival) C++14
100 / 100
9 ms 492 KB
// https://oj.uz/problem/view/CEOI14_carnival

#include <bits/stdc++.h>
using namespace std;

#define REP(i, j, k) for (int i = j; i < k; i++)
#define pb push_back

int n;
int ans[155];
vector<int> used;

int main() {
	scanf("%d", &n);
	ans[0] = 0;
	used.pb(0);
	REP (i, 1, n) {
		printf("%d", i + 1);
		REP (j, 0, i + 1) printf(" %d", j + 1);
		printf("\n");
		fflush(stdout);
		int all; scanf("%d", &all);
		if (all > used.size()) {
			used.pb(i);
			ans[i] = all - 1;
		} else {
			int lo = 0, hi = used.size() - 1, mid;
			while (lo < hi) {
				mid = hi + lo + 1 >> 1;
				printf("%d", mid - lo + 1);
				REP (i, lo, mid) printf(" %d", used[i] + 1);
				printf(" %d\n", i + 1);
				fflush(stdout);
				int cur; scanf("%d", &cur);
				if (cur == mid - lo) {
					hi = mid - 1;
				} else {
					lo = mid;
				}
			}
			ans[i] = hi;
		}
	}
	printf("0");
	REP (i, 0, n) printf(" %d", ans[i] + 1);
	printf("\n");
	return 0;
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:23:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |   if (all > used.size()) {
      |       ~~~~^~~~~~~~~~~~~
carnival.cpp:29:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   29 |     mid = hi + lo + 1 >> 1;
      |           ~~~~~~~~^~~
carnival.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
carnival.cpp:22:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   22 |   int all; scanf("%d", &all);
      |            ~~~~~^~~~~~~~~~~~
carnival.cpp:34:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   34 |     int cur; scanf("%d", &cur);
      |              ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 364 KB Output is correct
2 Correct 9 ms 364 KB Output is correct
3 Correct 6 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 3 ms 364 KB Output is correct
6 Correct 4 ms 364 KB Output is correct
7 Correct 8 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 364 KB Output is correct
2 Correct 9 ms 364 KB Output is correct
3 Correct 4 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 6 ms 364 KB Output is correct
6 Correct 7 ms 364 KB Output is correct
7 Correct 7 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 8 ms 364 KB Output is correct
3 Correct 8 ms 384 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 6 ms 364 KB Output is correct
6 Correct 7 ms 364 KB Output is correct
7 Correct 8 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 492 KB Output is correct
2 Correct 6 ms 364 KB Output is correct
3 Correct 5 ms 364 KB Output is correct
4 Correct 3 ms 364 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 7 ms 364 KB Output is correct
7 Correct 8 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 364 KB Output is correct
2 Correct 8 ms 364 KB Output is correct
3 Correct 7 ms 364 KB Output is correct
4 Correct 8 ms 364 KB Output is correct
5 Correct 4 ms 364 KB Output is correct
6 Correct 5 ms 364 KB Output is correct
7 Correct 4 ms 364 KB Output is correct