Submission #995861

# Submission time Handle Problem Language Result Execution time Memory
995861 2024-06-10T03:07:07 Z cowwycow Carnival (CEOI14_carnival) C++14
100 / 100
5 ms 600 KB
#include <bits/stdc++.h>
using namespace std;
#define name "aaaaaa"
using ll = long long;
using pii = pair<ll, ll>;

void file(){
}

const int maxn = 155;

int ask(vector<int> a){
	cout << a.size() << ' ';
	for(int i : a){
		cout << i << ' ';
	}
	cout << endl;
	int x; cin >> x;
	return x;
}

int ans[maxn];

vector<int> b;

void solve (){
	int n; cin >> n;
	ans[1] = 1;
	b.push_back(1);
	for(int i = 2; i <= n; i++){
		vector<int> cur = b;
		cur.push_back(i);
		if(ask(cur) == cur.size()){
			b.push_back(i);
			ans[i] = b.size();
		}else{
			int l = 0, r = b.size() - 1, mid, sus = 0;
			while(l <= r){
				mid = (l + r) / 2;
				cur.clear();
				for(int j = l; j <= mid; j++){
					cur.push_back(b[j]);
				}
				cur.push_back(i);
				if(ask(cur) == mid - l + 1){
					sus = mid;
					r = mid - 1;
				}else{
					l = mid + 1;
				}
			}
			ans[i] = ans[b[sus]];
		}
	}
	cout << 0 << ' ';
	for(int i = 1; i <= n; i++){
		cout << ans[i] << ' ';
	}
}

int main(){
	file();
	solve();
}

Compilation message

carnival.cpp: In function 'void solve()':
carnival.cpp:33:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |   if(ask(cur) == cur.size()){
      |      ~~~~~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 344 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 2 ms 436 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 2 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 3 ms 440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 4 ms 344 KB Output is correct
3 Correct 2 ms 344 KB Output is correct
4 Correct 2 ms 600 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 3 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 4 ms 344 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 4 ms 344 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 4 ms 416 KB Output is correct
3 Correct 2 ms 344 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 3 ms 440 KB Output is correct
7 Correct 5 ms 432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 5 ms 344 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 2 ms 344 KB Output is correct