답안 #996233

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
996233 2024-06-10T09:03:48 Z vjudge1 사육제 (CEOI14_carnival) C++17
100 / 100
5 ms 600 KB
#include <bits/stdc++.h>
using namespace std;
long long i, j, l, r, mid, p, p2, q, k, t, n, m, a, b, c, d, cnt, ans[205];
vector <long long> arr;
const long long mod = 9999919999;
string s;
bool check;
long long query (vector <long long> a){
	long long n = a.size();
	cout << n << " ";
	for (long long i = 0; i < n; i += 1){
		cout << a[i] << " ";
	}
	cout << endl;
	long long thl_bu_dau_sigma_top_1_doi_tuyen;
	cin >> thl_bu_dau_sigma_top_1_doi_tuyen;
	return thl_bu_dau_sigma_top_1_doi_tuyen;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	arr.push_back(1);
	for (i = 2; i <= n; i += 1){
		vector <long long> res = arr;
		res.push_back(i);
		if (query(res) == res.size()){
			arr.push_back(i);
			ans[i] = arr.size();
		}
		else{
			l = 0;
			r = arr.size() - 1;
			p = 0;
			while (l <= r){
				mid = (l + r) >> 1;
				res.clear();
				for (j = l; j <= mid; j += 1){
					res.push_back(arr[j]);
				}
				res.push_back(i);
				if (query(res) == mid - l + 1){
					p = arr[mid];
					r = mid - 1;
				}
				else{
					l = mid + 1;
				}
			}
			ans[i] = ans[p];
			ans[i] = max(ans[i], 1ll);
		}
	}
	cout << 0 << " " << 1 << " ";
	for (i = 2; i <= n; i += 1){
		cout << ans[i] << " ";
	}
	cout << endl;
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:29:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |   if (query(res) == res.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 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 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 4 ms 344 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 4 ms 452 KB Output is correct
6 Correct 3 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 3 ms 344 KB Output is correct
3 Correct 3 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 452 KB Output is correct
7 Correct 3 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 4 ms 344 KB Output is correct
3 Correct 3 ms 488 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 344 KB Output is correct
7 Correct 3 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 480 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 3 ms 468 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 2 ms 600 KB Output is correct