QOJ.ac

QOJ

IDSubmission IDProblemHackerOwnerResultSubmit timeJudge time
#529#319749#21694. 【NOIP Round #3】抓内鬼cz2010124zhangchaozheng2030Failed.2024-02-03 10:17:072024-02-03 10:17:07

Details

Extra Test:

Invalid Input

input:

a
s1d3a2s1d 3

output:


result:

FAIL Expected integer, but "a" found (stdin, line 1)

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#319749#21694. 【NOIP Round #3】抓内鬼zhangchaozheng2030100 ✓75ms4260kbC++14648b2024-02-03 08:03:472024-02-03 08:03:48

answer

#include <bits/stdc++.h>
using namespace std;
int n,m,v,u;
bitset<100005> tn,t1;
char s[100005];
#define c(a,b) (s[a]=b?(u--,'U'):(v--,'P'))
int main(){
	cin>>n>>m>>u;
	v=n-u;
	for(int i=1,w;i<=n;i++) cin>>w;
	for(int i=1,u,v;i<=m;i++){
		cin>>u>>v;
		if(u>v) swap(u,v);
		if(u==1) t1[v]=1;
		if(v==n) tn[u]=1;
	}
	if(t1[n]){
		if(v==1&&u==1) exit((cout<<"impossible")&&0);
		if(v>1) c(1,0),c(n,0);
		else c(1,1),c(n,1);
		for(int i=2;i<n;i++) c(i,u);
	}
	else{
		basic_string<int> A(1,1),B(1,n);
		for(int i=2;i<n;i++) ((t1[i]&&!tn[i])?A:B)+=i;
		reverse(B.begin(),B.end());
		for(int i:A+B) c(i,u);
	}
	cout<<(s+1);
}