QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#63327#1774. Customs ControlsNeverWA 1ms3284kbC++141.4kb2022-11-21 18:47:402022-11-21 18:47:43

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-11-21 18:47:43]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3284kb
  • [2022-11-21 18:47:40]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,m,k,tt,u,v,t[4];
bool flag,bz[N];
char ans[N];
int main(){
//	freopen("catch.in","r",stdin);
//	freopen("catch.out","w",stdout);
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++) scanf("%d",&tt);
	bz[1]=1;bz[n]=2;
	t[1]=1;t[2]=1;
	for(int i=1;i<=m;i++){
		scanf("%d%d",&u,&v);
		if((u==1&&v==n)||(v==1&&u==n)) flag=1;
		else{
			if(u==1) bz[v]+=1;
			if(v==1) bz[u]+=1;
			if(u==n) bz[v]+=2;
			if(v==n) bz[u]+=2;
		}
	}
	if(k==0){
		for(int i=1;i<=n;i++) putchar('S');
		return 0;
	}
	if(k==n){
		for(int i=1;i<=n;i++) putchar('N');
		return 0;
	}
	if(flag){
		if(n==2) puts("impossible");
		else{
			if(k>=2){
				putchar('S');
				for(int i=1;i<=k-2;i++) putchar('S');
				for(int i=1;i<=n-k;i++) putchar('N');
				putchar('S');
			}
			else{
				putchar('S');
				for(int i=1;i<=k;i++) putchar('N');
				for(int i=1;i<=n-k-1;i++) putchar('S');
			}
		}
		return 0;
	}
	for(int i=1;i<=n;i++) t[bz[i]]++;
	ans[1]='S';
	ans[n]='N';
	if(t[1]<=k){
		for(int i=1;i<=n;i++) if(bz[i]==1) ans[i]='N';
		for(int i=1,j=k-t[1];i<=n;i++,j--){
			if(ans[i]) continue;
			if(j>0) ans[i]='N';
			else ans[i]='S';
		}
	}
	else{
		for(int i=1;i<=n;i++) if(bz[i]>=2) ans[i]='S';
		for(int i=1,j=k;i<=n;i++,j--){
			if(ans[i]) continue;
			if(j>0) ans[i]='N';
			else ans[i]='S';
		}
	}
	for(int i=1;i<=n;i++) putchar(ans[i]);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3284kb

input:

5 10 2
1 1 1 1 1
3 4
5 4
3 1
4 1
3 5
2 1
2 4
2 5
1 5
2 3

output:

SNNNS

result:

wrong answer number of N:s not equal to k