답안 #995863

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
995863 2024-06-10T03:07:32 Z vjudge1 사육제 (CEOI14_carnival) C++14
100 / 100
6 ms 1368 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()){
      |      ~~~~~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 3 ms 1368 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 3 ms 440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 6 ms 600 KB Output is correct
3 Correct 3 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 2 ms 344 KB Output is correct
7 Correct 3 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 6 ms 344 KB Output is correct
4 Correct 2 ms 456 KB Output is correct
5 Correct 4 ms 436 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 4 ms 432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 3 ms 344 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 4 ms 344 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 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 436 KB Output is correct
6 Correct 2 ms 444 KB Output is correct
7 Correct 2 ms 344 KB Output is correct