Submission #116765

# Submission time Handle Problem Language Result Execution time Memory
116765 2019-06-13T18:41:13 Z Noam527 Carnival (CEOI14_carnival) C++17
100 / 100
21 ms 512 KB
#include <bits/stdc++.h>
#define finish(x) return cout << x << endl, 0
typedef long long ll;
typedef long double ldb;
const int md = 1e9 + 7;
const ll inf = 1e18;
const int OO = 1;
const int OOO = 1;
using namespace std;

int ask(int P, int extra = -1) {
	if (extra <= P) {
		cout << P << " ";
		for (int i = 1; i <= P; i++) cout << i << " ";
		cout << endl;
		fflush(stdout);
	}
	else {
		cout << P + 1 << " ";
		for (int i = 1; i <= P; i++) cout << i << " ";
		cout << extra << endl;
		fflush(stdout);
	}
	int rtn;
	cin >> rtn;
	return rtn;
}

int n;
int P[200];
int ans[200];

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) P[i] = ask(i);
	int nxt = 1;
	for (int i = 1; i <= n; i++) {
		int lo = 1, hi = i, mid;
		while (lo < hi) {
			mid = (lo + hi) / 2;
			if (P[mid] == ask(mid, i)) hi = mid;
			else lo = mid + 1;
		}
		if (i == lo) ans[i] = nxt++;
		else ans[i] = ans[lo];
	}
	cout << "0 ";
	for (int i = 1; i <= n; i++) cout << ans[i] << " "; cout << '\n';
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:49:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for (int i = 1; i <= n; i++) cout << ans[i] << " "; cout << '\n';
  ^~~
carnival.cpp:49:54: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  for (int i = 1; i <= n; i++) cout << ans[i] << " "; cout << '\n';
                                                      ^~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 15 ms 256 KB Output is correct
3 Correct 10 ms 256 KB Output is correct
4 Correct 12 ms 256 KB Output is correct
5 Correct 9 ms 384 KB Output is correct
6 Correct 13 ms 256 KB Output is correct
7 Correct 9 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 384 KB Output is correct
2 Correct 10 ms 384 KB Output is correct
3 Correct 8 ms 384 KB Output is correct
4 Correct 10 ms 384 KB Output is correct
5 Correct 11 ms 256 KB Output is correct
6 Correct 13 ms 384 KB Output is correct
7 Correct 12 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 384 KB Output is correct
2 Correct 14 ms 384 KB Output is correct
3 Correct 14 ms 284 KB Output is correct
4 Correct 8 ms 384 KB Output is correct
5 Correct 10 ms 384 KB Output is correct
6 Correct 11 ms 256 KB Output is correct
7 Correct 7 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 9 ms 384 KB Output is correct
3 Correct 14 ms 256 KB Output is correct
4 Correct 14 ms 384 KB Output is correct
5 Correct 14 ms 256 KB Output is correct
6 Correct 21 ms 384 KB Output is correct
7 Correct 12 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 512 KB Output is correct
2 Correct 11 ms 256 KB Output is correct
3 Correct 14 ms 256 KB Output is correct
4 Correct 8 ms 384 KB Output is correct
5 Correct 13 ms 384 KB Output is correct
6 Correct 8 ms 384 KB Output is correct
7 Correct 11 ms 384 KB Output is correct