Submission #197432

# Submission time Handle Problem Language Result Execution time Memory
197432 2020-01-21T07:03:54 Z Juney Carnival (CEOI14_carnival) C++14
100 / 100
24 ms 424 KB
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e5 + 5;

int N, col[155];
vector<int> V;

void out(vector<int> &v) {
	cout << v.size() << ' ';
	for(auto i : v) cout << i << ' ';
	cout << endl;
}

int search(int x) {
	int l = 0, r = V.size() - 1, ret;
	while(l <= r) {
		if(l == r) {
			ret = l;
			break;
		}
		int mid = l + r >> 1;
		vector<int> t; t.push_back(x);
		for(int i=l; i<=mid; i++) t.push_back(V[i]);
		out(t);
		int a; cin >> a;
		if(a == mid - l + 1) r = mid;
		else l = mid + 1;
	}
	return ret + 1;
}

int main() {
	//ios::sync_with_stdio(0); cin.tie(0);
	cin >> N;
	V.push_back(1); col[1] = 1;
	for(int i=2; i<=N; i++) {
		V.push_back(i);
		out(V);
		int x; cin >> x;
		if(x < V.size()) {
			V.pop_back();
			int c = search(i);
			col[i] = c;
		}
		else col[i] = V.size();
	}
	cout << 0 << ' ';
	for(int i=1; i<=N; i++) cout << col[i] << ' ';
	cout << endl;
}

Compilation message

carnival.cpp: In function 'int search(int)':
carnival.cpp:29:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int mid = l + r >> 1;
             ~~^~~
carnival.cpp: In function 'int main()':
carnival.cpp:48:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(x < V.size()) {
      ~~^~~~~~~~~~
carnival.cpp: In function 'int search(int)':
carnival.cpp:23:31: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
  int l = 0, r = V.size() - 1, ret;
                               ^~~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 376 KB Output is correct
2 Correct 9 ms 248 KB Output is correct
3 Correct 7 ms 248 KB Output is correct
4 Correct 6 ms 248 KB Output is correct
5 Correct 6 ms 248 KB Output is correct
6 Correct 6 ms 296 KB Output is correct
7 Correct 9 ms 248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 376 KB Output is correct
2 Correct 15 ms 252 KB Output is correct
3 Correct 4 ms 248 KB Output is correct
4 Correct 4 ms 248 KB Output is correct
5 Correct 9 ms 248 KB Output is correct
6 Correct 4 ms 396 KB Output is correct
7 Correct 9 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 8 ms 376 KB Output is correct
3 Correct 9 ms 248 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 5 ms 380 KB Output is correct
6 Correct 10 ms 276 KB Output is correct
7 Correct 11 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 4 ms 248 KB Output is correct
3 Correct 7 ms 376 KB Output is correct
4 Correct 5 ms 248 KB Output is correct
5 Correct 10 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 10 ms 248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 424 KB Output is correct
2 Correct 11 ms 376 KB Output is correct
3 Correct 24 ms 248 KB Output is correct
4 Correct 6 ms 248 KB Output is correct
5 Correct 9 ms 248 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 6 ms 376 KB Output is correct