QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#63335#1774. Customs ControlsNeverWA 2ms3604kbC++141.4kb2022-11-21 19:12:432022-11-21 19:12: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 19:12:43]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3604kb
  • [2022-11-21 19:12:43]
  • 提交

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;
	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('N');
				for(int i=1;i<=k-2;i++) putchar('N');
				for(int i=1;i<=n-k;i++) putchar('S');
				putchar('N');
			}
			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]='N';
	ans[n]='S';
	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-1;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;
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 3604kb

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:

NSSSN

result:

ok accepted

Test #2:

score: 0
Accepted
time: 2ms
memory: 3468kb

input:

10 9 5
1 1 1 1 1 1 1 1 1 1
9 5
7 1
8 1
10 1
5 3
6 1
2 1
3 2
4 1

output:

NNNNSSSSSN

result:

ok accepted

Test #3:

score: 0
Accepted
time: 1ms
memory: 3604kb

input:

2 1 2
6124 7094
2 1

output:

NN

result:

ok accepted

Test #4:

score: 0
Accepted
time: 2ms
memory: 3284kb

input:

2 1 1
6901 1417
2 1

output:

impossible

result:

ok accepted

Test #5:

score: -100
Wrong Answer
time: 2ms
memory: 3604kb

input:

50 67 25
5 10 5 4 3 3 8 7 10 4 6 6 9 8 5 1 5 9 3 2 3 8 9 9 2 8 7 8 9 8 3 3 10 7 5 5 7 1 6 9 4 6 9 10 4 10 9 10 9 5
45 35
27 17
11 14
34 1
49 37
4 2
9 3
42 9
13 25
40 32
38 17
28 1
26 14
13 19
41 40
38 40
12 6
14 7
47 25
30 21
32 22
7 6
16 12
15 9
20 16
29 3
21 8
19 9
18 23
43 5
5 3
11 35
10 7
36 16
...

output:

NNNNNNNNNNNNNNNNNSSSSSNSSSSNSSSSSNSSSSSSSSSSSSSSSN

result:

wrong answer number of N:s not equal to k