Submission #604838

# Submission time Handle Problem Language Result Execution time Memory
604838 2022-07-25T10:20:00 Z CSQ31 ICC (CEOI16_icc) C++17
61 / 100
164 ms 504 KB
#include <bits/stdc++.h>
#include "icc.h"
using namespace std;
int par[1000];
int find(int x){
	if(x==par[x])return x;
	return par[x] = find(par[x]);
}
void unite(int a,int b){
	a = find(a);
	b = find(b);
	if(a==b)return;
	par[a] = b;
	
}
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int n;
int A[200],B[200],an,bn;
/*
int query(int a, int b, int *A, int *B){
	int ans;
	for(int i=0;i<a;i++)cout<<A[i]<<" ";
	cout<<'\n';
	for(int i=0;i<b;i++)cout<<B[i]<<" ";
	cout<<'\n';
	cin>>ans;
	return ans;
}
void setRoad(int a, int b){
	cout<<"added edge"<<'\n';
	cout<<a<<" "<<b<<'\n';
}*/
void run(int N){
	n = N;
	for(int i=1;i<=n;i++)par[i] = i;
	for(int i=1;i<n;i++){
		vector<int>g;
		vector<vector<int>>p(n+1);
		for(int j=1;j<=n;j++){
			if(j==find(j))g.push_back(j);
			p[find(j)].push_back(j);
		}
		while(true){
			shuffle(g.begin(),g.end(),rng);
			int m = g.size();
			int ptr = 0;
			for(int k=0;k<m/2;k++){
				for(int x:p[g[k]])A[ptr++] = x;
			}
			an = ptr;
			bn = n-ptr;
			ptr = 0;
			for(int k=m/2;k<m;k++){
				for(int x:p[g[k]])B[ptr++] = x;
			}
			if(query(an,bn,A,B))break;
		}
		int l = 1,r = an;
		while(r>l){
			int mid = (l+r)/2;
			if(query(mid,bn,A,B))r = mid;
			else l = mid+1;
			
		}
		int v = A[r-1];
		l = 1;
		r = bn;
		while(r>l){
			int mid = (l+r)/2;
			if(query(an,mid,A,B))r = mid;
			else l = mid+1;
		}
		int u = B[r-1];
		unite(v,u);
		setRoad(v,u);
	}
	
}
/*
int main()
{
	int m;
	cin>>m;
	run(m);
	
}*/
# Verdict Execution time Memory Grader output
1 Correct 6 ms 504 KB Ok! 98 queries used.
2 Correct 7 ms 504 KB Ok! 104 queries used.
# Verdict Execution time Memory Grader output
1 Correct 26 ms 468 KB Ok! 536 queries used.
2 Correct 42 ms 468 KB Ok! 830 queries used.
3 Correct 42 ms 484 KB Ok! 800 queries used.
# Verdict Execution time Memory Grader output
1 Correct 115 ms 492 KB Ok! 1475 queries used.
2 Correct 164 ms 492 KB Ok! 2094 queries used.
3 Correct 121 ms 468 KB Ok! 1723 queries used.
4 Correct 123 ms 492 KB Ok! 1717 queries used.
# Verdict Execution time Memory Grader output
1 Correct 115 ms 492 KB Ok! 1554 queries used.
2 Correct 117 ms 488 KB Ok! 1613 queries used.
3 Correct 138 ms 468 KB Ok! 1865 queries used.
4 Correct 110 ms 488 KB Ok! 1587 queries used.
# Verdict Execution time Memory Grader output
1 Incorrect 155 ms 496 KB Too many queries! 1883 out of 1775
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 130 ms 492 KB Too many queries! 1813 out of 1625
2 Halted 0 ms 0 KB -