Submission #362164

# Submission time Handle Problem Language Result Execution time Memory
362164 2021-02-01T22:19:31 Z evn Carnival (CEOI14_carnival) C++14
100 / 100
33 ms 384 KB
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
typedef long long ll;
typedef pair<int, int> pii;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main(){

	//ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int N;
	cin >> N;
	cout << N;
	for(int i = 1; i<= N;i ++){
		cout << " " << i; 
	} 
	cout << '\n';
	fflush(stdout);
	int C;
	cin >> C;
	vector<int> pref(C+1);
	vector<int> ans(N+1);
	for(int i = C;i >= 1; i--){
		//binary search for where the first prefix that has i distinct
		int lo = 1;
		int hi = N;
		while(lo < hi){
			int mid = (lo+hi)/2;
			cout << mid;
			for(int j = 1; j <= mid;j ++){
				cout << " " << j;
			}
			cout << '\n';
			fflush(stdout);
			int amt; 
			cin >> amt;
			if(amt < i){
				//more distinct needed
				lo = mid+1;
			}
			else{
				hi = mid;
			}
			
		}
		pref[i] = lo;
	}
	for(int i = 1;i <= C; i++){
		ans[pref[i]] = i;
		//cout << pref[i] << '\n';
	}
	int ptr = 1;
	for(int i = 1;i <= N;i ++){
		if(i >= pref[ptr])ptr++;
		if(ans[i] == 0){
			for(int j = 1; j <= ptr; j++){
				cout << 2 << " " << pref[j] << " " << i << '\n';
				fflush(stdout);
				int curr;
				cin >> curr;
				if(curr == 1){
					ans[i] = j;
					break;
				}
			}
		}
	}
	cout << 0;
	for(int i = 1; i<=N;i ++){
		cout << " " << ans[i];
	}
	cout << '\n';
	fflush(stdout);
}
# Verdict Execution time Memory Grader output
1 Correct 9 ms 384 KB Output is correct
2 Correct 19 ms 364 KB Output is correct
3 Correct 25 ms 364 KB Output is correct
4 Correct 19 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 13 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 364 KB Output is correct
2 Correct 18 ms 364 KB Output is correct
3 Correct 12 ms 364 KB Output is correct
4 Correct 20 ms 364 KB Output is correct
5 Correct 3 ms 364 KB Output is correct
6 Correct 3 ms 364 KB Output is correct
7 Correct 7 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 6 ms 364 KB Output is correct
3 Correct 25 ms 364 KB Output is correct
4 Correct 19 ms 364 KB Output is correct
5 Correct 7 ms 364 KB Output is correct
6 Correct 8 ms 364 KB Output is correct
7 Correct 19 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 364 KB Output is correct
2 Correct 5 ms 364 KB Output is correct
3 Correct 26 ms 364 KB Output is correct
4 Correct 21 ms 364 KB Output is correct
5 Correct 7 ms 364 KB Output is correct
6 Correct 11 ms 364 KB Output is correct
7 Correct 16 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 364 KB Output is correct
2 Correct 12 ms 364 KB Output is correct
3 Correct 33 ms 364 KB Output is correct
4 Correct 25 ms 364 KB Output is correct
5 Correct 13 ms 380 KB Output is correct
6 Correct 15 ms 364 KB Output is correct
7 Correct 23 ms 364 KB Output is correct