QOJ.ac

QOJ

IDSubmission IDProblemHackerOwnerResultSubmit timeJudge time
#1033#663691#21694. 【NOIP Round #3】抓内鬼wth2026wyl2026Failed.2024-10-21 19:51:112024-10-21 19:51:12

Details

Extra Test:

Invalid Input

input:

2 1 1
1
1 1

output:


result:

FAIL Unexpected character #10, but ' ' expected (stdin, line 2)

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#663691#21694. 【NOIP Round #3】抓内鬼wyl2026100 ✓22ms5924kbC++141.9kb2024-10-21 16:46:362024-10-21 16:46:37

answer

#include<bits/stdc++.h>
using namespace std;
namespace WYL{
	const int N=2e5+10;
	int t[N],x[N],y[N],n,m,k,cntx,cnty,cnt;
	char ans[N];
	void check(){
		if(k==n){
			for(int i=1;i<=n;i++){
				ans[i]='U';
			}
			for(int i=1;i<=n;i++){
				cout<<ans[i];
			}
			cout<<endl;
			exit(0);
		}
		if(k==0){
			for(int i=1;i<=n;i++){
				ans[i]='P';
			}
			for(int i=1;i<=n;i++){
				cout<<ans[i];
			}
			cout<<endl;
			exit(0);
		}
		return;
	}
	int main(){
		cin>>n>>m>>k;
		for(int i=1;i<=n;i++){
			cin>>t[i];
		}
		check();
		int flag=0;
		for(int i=1;i<=m;i++){
			int u,v;
			cin>>u>>v;
			if(u==1&&v==n||u==n&&v==1){
				flag=1;
				continue;
			}
			if(u==1){
				cntx++;
				x[v]=1;
			}
			if(u==n){
				cnty++;
				y[v]=1;
			}
			if(v==1){
				cntx++;
				x[u]=1;
			}
			if(v==n){
				cnty++;
				y[u]=1;
			}
		}
		if(flag){
			if(n==2){
				cout<<"impossible"<<endl;
				return 0;
			}
			cnt=2;
			if(k*2<=n){
				ans[1]=ans[n]='P';
				for(int i=2;i<n;i++){
					if(cnt<n-k){
						cnt++;
						ans[i]='P';
					}else{
						ans[i]='U';
					}
				}
			}else{
				ans[1]=ans[n]='U';
				for(int i=2;i<n;i++){
					if(cnt<k){
						cnt++;
						ans[i]='U';
					}else{
						ans[i]='P';
					}
				}
			}
			for(int i=1;i<=n;i++){
				cout<<ans[i];
			}
			cout<<endl;
			return 0;
		}
		ans[1]='U';
		ans[n]='P';
		cnt=1;
		for(int i=1;i<=n;i++){
			if(cnt==k){
				break;
			}
			if(x[i]){
				ans[i]='U';
				cnt++;
			}
		}
		for(int i=1;i<=n;i++){
			if(!ans[i]){
				if(cnt<k){
					ans[i]='U';
					cnt++;
				}else{
					ans[i]='P';
				}
			}
		}
		for(int i=1;i<=n;i++){
			cout<<ans[i];
		}
		cout<<endl;
		return 0;
	}
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	// freopen("catch.in","r",stdin);
	// freopen("catch.out","w",stdout);
	WYL::main();
	return 0;
}