답안 #105515

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
105515 2019-04-13T07:26:42 Z faustaadp Zagonetka (COI18_zagonetka) C++17
0 / 100
90 ms 512 KB
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
using namespace std;
ll n,a[110],tany[110],i,j,b1[110],b2[110],te1,te2,jaw1[110],jaw2[110];
vector<ll> v1[110],v2[110];
ll tanya()
{
	cout<<"query";
	ll ii;
	for(ii=1;ii<=n;ii++)cout<<" "<<tany[ii];
	cout<<endl;
	ll H=0;
	cin>>H;
	return H;
}
void cek(ll aa,ll bb)
{
	ll ii;
	vector<pair<ll,ll> > A;
	for(ii=1;ii<=n;ii++)
		if(ii!=aa&&ii!=bb)
			A.pb(mp(a[ii],ii));
	sort(A.begin(),A.end());
	for(ii=0;ii<A.size();ii++)
		tany[A[ii].se]=ii+1;
	if(a[aa]<a[bb])
	{
		tany[aa]=n;
		tany[bb]=n-1;
	}
	else
	{
		tany[aa]=n-1;
		tany[bb]=n;
	}
	if(!tanya())
	{
		if(a[aa]<a[bb])v1[aa].pb(bb);
		else v1[bb].pb(aa);
		if(a[aa]<a[bb])v2[aa].pb(bb);
		else v2[bb].pb(aa);
	}
}
void dfs1(ll aa)
{
	b1[aa]=1;
	ll ii;
	for(ii=0;ii<v1[aa].size();ii++)
		if(!b1[v1[aa][ii]])
			dfs1(v1[aa][ii]);
	jaw1[aa]=te1;
	te1--;
}
void dfs2(ll aa)
{
	b2[aa]=1;
	ll ii;
	for(ii=0;ii<v2[aa].size();ii++)
		if(!b2[v2[aa][ii]])
			dfs2(v2[aa][ii]);
	jaw2[aa]=te2;
	te2--;
}
int main()
{
	//ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n;
	for(i=1;i<=n;i++)cin>>a[i];
	for(i=1;i<=n;i++)
		for(j=i+1;j<=n;j++)
			cek(i,j);
	cout<<"end"<<endl;
	for(i=1;i<=n;i++)sort(v1[i].begin(),v1[i].end());
	for(i=1;i<=n;i++)sort(v2[i].begin(),v2[i].end());
	for(i=1;i<=n;i++)reverse(v1[i].begin(),v1[i].end());
	te1=n;
	for(i=n;i>=1;i--)
		if(!b1[i])
			dfs1(i);
	te2=n;
	for(i=1;i<=n;i++)
		if(!b2[i])
			dfs2(i);
	for(i=1;i<=n;i++)
		if(i<n)cout<<jaw1[i]<<" ";
		else cout<<jaw1[i]<<endl;
	for(i=1;i<=n;i++)
		if(i<n)cout<<jaw2[i]<<" ";
		else cout<<jaw2[i]<<endl;
}

Compilation message

zagonetka.cpp: In function 'void cek(ll, ll)':
zagonetka.cpp:28:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(ii=0;ii<A.size();ii++)
           ~~^~~~~~~~~
zagonetka.cpp: In function 'void dfs1(ll)':
zagonetka.cpp:52:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(ii=0;ii<v1[aa].size();ii++)
           ~~^~~~~~~~~~~~~~
zagonetka.cpp: In function 'void dfs2(ll)':
zagonetka.cpp:62:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(ii=0;ii<v2[aa].size();ii++)
           ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 90 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -