Submission #230236

# Submission time Handle Problem Language Result Execution time Memory
230236 2020-05-09T09:34:07 Z syy Carnival (CEOI14_carnival) C++17
0 / 100
5 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";
	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"; 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";
	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:29: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:43:2: note: in expansion of macro 'FOR'
  FOR(i, 0, n) cout << col[i] << " "; cout << "\n";
  ^~~
carnival.cpp:43: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";
                                      ^~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 5 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5 ms 384 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5 ms 384 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5 ms 384 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5 ms 384 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -