답안 #230238

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
230238 2020-05-09T09:35:46 Z syy 사육제 (CEOI14_carnival) C++17
100 / 100
14 ms 384 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int n, c, col[155], r;
vector<int> v;

int query(int x, int y, int z = 0) {
	cout << y-x+1+(z != 0)<< " ";
	while (x <= y) cout << v[x++] << " ";
	if (z) cout << z; cout << "\n";
	cout.flush();
	int res; cin >> res;
	return res;
}

int main() {
	fastio; cin >> n;
	FOR(i, 1, n) {
		v.pb(i);
		if (v.size() != query(0, v.size()-1)) v.pop_back();
	}
	c = v.size(); FOR(i, 0, c-1) col[v[i]] = i+1;
	FOR(i, 1, n) if (!col[i]) {
		int lower = 0, upper = c-1;
		while (upper - lower > 1) {
			int mid = (upper + lower)/2;
			if (query(lower, mid, i) != mid-lower+2) upper = mid;
			else lower = mid+1;
		}
		cout << "2 " << v[lower] << " " << i << "\n"; cout.flush(); cin >> r;
		if (r == 1) col[i] = col[v[lower]];
		else col[i] = col[v[upper]];
	}
	FOR(i, 0, n) cout << col[i] << " "; cout << "\n"; cout.flush();
	return 0;
}

Compilation message

carnival.cpp: In function 'int query(int, int, int)':
carnival.cpp:20:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
  if (z) cout << z; cout << "\n";
  ^~
carnival.cpp:20:20: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
  if (z) cout << z; cout << "\n";
                    ^~~~
carnival.cpp: In function 'int main()':
carnival.cpp:30:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (v.size() != query(0, v.size()-1)) v.pop_back();
       ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
carnival.cpp:5:22: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
 #define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
                      ^
carnival.cpp:44:2: note: in expansion of macro 'FOR'
  FOR(i, 0, n) cout << col[i] << " "; cout << "\n"; cout.flush();
  ^~~
carnival.cpp:44:38: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  FOR(i, 0, n) cout << col[i] << " "; cout << "\n"; cout.flush();
                                      ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 384 KB Output is correct
2 Correct 12 ms 384 KB Output is correct
3 Correct 9 ms 384 KB Output is correct
4 Correct 7 ms 384 KB Output is correct
5 Correct 9 ms 384 KB Output is correct
6 Correct 7 ms 384 KB Output is correct
7 Correct 11 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 384 KB Output is correct
2 Correct 11 ms 256 KB Output is correct
3 Correct 8 ms 384 KB Output is correct
4 Correct 7 ms 384 KB Output is correct
5 Correct 10 ms 384 KB Output is correct
6 Correct 8 ms 384 KB Output is correct
7 Correct 9 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 384 KB Output is correct
2 Correct 9 ms 384 KB Output is correct
3 Correct 11 ms 384 KB Output is correct
4 Correct 7 ms 384 KB Output is correct
5 Correct 10 ms 384 KB Output is correct
6 Correct 11 ms 384 KB Output is correct
7 Correct 12 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 384 KB Output is correct
2 Correct 10 ms 384 KB Output is correct
3 Correct 8 ms 360 KB Output is correct
4 Correct 7 ms 384 KB Output is correct
5 Correct 12 ms 384 KB Output is correct
6 Correct 10 ms 384 KB Output is correct
7 Correct 14 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 384 KB Output is correct
2 Correct 10 ms 384 KB Output is correct
3 Correct 12 ms 384 KB Output is correct
4 Correct 10 ms 384 KB Output is correct
5 Correct 9 ms 384 KB Output is correct
6 Correct 9 ms 384 KB Output is correct
7 Correct 8 ms 384 KB Output is correct