답안 #152016

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
152016 2019-09-05T21:13:26 Z MvC CEOI16_icc (CEOI16_icc) C++11
90 / 100
162 ms 692 KB
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
#include "icc.h"
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<61);
const int inf=(1<<30);
const int nmax=1e2+50;
const int mod=1e9+7;
using namespace std;
int n,i,sa,sb,aa[nmax],ab[nmax],j,edd,va[nmax],m,b,v;
vector<int>a[nmax],vc,rad;
vector<vector<int> >cc;
bitset<nmax>viz;
int qry(int sa,int sb,int aa[],int ab[])
{
	return query(sa,sb,aa,ab);
	cout<<"?"<<endl;
	for(int i=0;i<sa;i++)cout<<aa[i]<<" ";
	cout<<endl;
	for(int i=0;i<sb;i++)cout<<ab[i]<<" ";
	cout<<endl;
	int x;
	cin>>x;
	return x;
}
/*void setRoad(int x,int y)
{
	cout<<"! "<<x<<" "<<y<<endl;
}*/
void dfs(int x)
{
	viz[x]=1;
	vc.pb(x);
	for(int i=0;i<a[x].size();i++)
	{
		int y=a[x][i];
		if(viz[y])continue;
		dfs(y);
	}
}
void dc(int l,int r,int ar[],int lb,int st[])
{
	if(l==r)
	{
		vc.pb(ar[l]);
		return;
	}
	int mid=(l+r)/2;
	int xa=0;
	for(int i=l;i<=mid;i++)va[xa++]=ar[i];
	if(qry(xa,lb,va,st))dc(l,mid,ar,lb,st);
	else dc(mid+1,r,ar,lb,st);
}
void run(int N)
{
	srand(time(0));
	n=N;
	for(edd=1;edd<n;edd++)
	{
		viz.reset();
		cc.clear();
		for(i=1;i<=n;i++)
		{
			if(viz[i])continue;
			vc.clear();
			dfs(i);
			cc.pb(vc);
		}
		rad.clear();
		for(i=0;;i++)
		{
			if((1<<i)>=cc.size())break;
			rad.pb(i);
		}
		random_shuffle(rad.begin(),rad.end());
		v=rand()%2;
		if(v)
		{
			for(b=rad.size()-1;b>=0;b--)
			{
				sa=sb=0;
				for(i=0;i<cc.size();i++)
				{
					if(i&(1<<rad[b]))
					{
						for(j=0;j<cc[i].size();j++)aa[sa++]=cc[i][j];
					}
					else
					{
						for(j=0;j<cc[i].size();j++)ab[sb++]=cc[i][j];
					}
				}
				if(qry(sa,sb,aa,ab))break;
			}
		}
		else
		{
			for(b=0;b<rad.size();b++)
			{
				sa=sb=0;
				for(i=0;i<cc.size();i++)
				{
					if(i&(1<<rad[b]))
					{
						for(j=0;j<cc[i].size();j++)aa[sa++]=cc[i][j];
					}
					else
					{
						for(j=0;j<cc[i].size();j++)ab[sb++]=cc[i][j];
					}
				}
				if(qry(sa,sb,aa,ab))break;
			}
		}
		vc.clear();
		dc(0,sa-1,aa,sb,ab);
		dc(0,sb-1,ab,sa,aa);
		setRoad(vc[0],vc[1]);
		a[vc[0]].pb(vc[1]);
		a[vc[1]].pb(vc[0]);
	}
}
/*int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	int z;
	cin>>z;
	run(z);
	return 0;
}*/

Compilation message

icc.cpp:2:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("O3")
 
icc.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("unroll-loops")
 
icc.cpp: In function 'void dfs(int)':
icc.cpp:46:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<a[x].size();i++)
              ~^~~~~~~~~~~~
icc.cpp: In function 'void run(int)':
icc.cpp:84:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if((1<<i)>=cc.size())break;
       ~~~~~~^~~~~~~~~~~
icc.cpp:94:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(i=0;i<cc.size();i++)
             ~^~~~~~~~~~
icc.cpp:98:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for(j=0;j<cc[i].size();j++)aa[sa++]=cc[i][j];
               ~^~~~~~~~~~~~~
icc.cpp:102:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for(j=0;j<cc[i].size();j++)ab[sb++]=cc[i][j];
               ~^~~~~~~~~~~~~
icc.cpp:110:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(b=0;b<rad.size();b++)
            ~^~~~~~~~~~~
icc.cpp:113:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(i=0;i<cc.size();i++)
             ~^~~~~~~~~~
icc.cpp:117:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for(j=0;j<cc[i].size();j++)aa[sa++]=cc[i][j];
               ~^~~~~~~~~~~~~
icc.cpp:121:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for(j=0;j<cc[i].size();j++)ab[sb++]=cc[i][j];
               ~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 504 KB Ok! 104 queries used.
2 Correct 8 ms 504 KB Ok! 100 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 504 KB Ok! 527 queries used.
2 Correct 50 ms 632 KB Ok! 668 queries used.
3 Correct 49 ms 504 KB Ok! 657 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 139 ms 604 KB Ok! 1440 queries used.
2 Correct 161 ms 568 KB Ok! 1668 queries used.
3 Correct 154 ms 504 KB Ok! 1638 queries used.
4 Correct 144 ms 632 KB Ok! 1524 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 151 ms 636 KB Ok! 1574 queries used.
2 Correct 146 ms 504 KB Ok! 1533 queries used.
3 Correct 154 ms 568 KB Ok! 1627 queries used.
4 Correct 148 ms 504 KB Ok! 1568 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 154 ms 632 KB Ok! 1595 queries used.
2 Correct 160 ms 572 KB Ok! 1625 queries used.
3 Correct 159 ms 692 KB Ok! 1648 queries used.
4 Correct 159 ms 572 KB Ok! 1613 queries used.
5 Correct 142 ms 560 KB Ok! 1499 queries used.
6 Correct 152 ms 560 KB Ok! 1568 queries used.
# 결과 실행 시간 메모리 Grader output
1 Incorrect 162 ms 564 KB Too many queries! 1654 out of 1625
2 Halted 0 ms 0 KB -