QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#190579#1774. Customs ControlsZhouShangWA 7ms29892kbC++14722b2023-09-29 06:20:522023-09-29 06:20:53

Judging History

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

  • [2023-09-29 06:20:53]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:29892kb
  • [2023-09-29 06:20:52]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n,m,k,a[1<<20],x,y;
vector<int>e[1<<20];
queue<int>q;
int main(){
	cin>>n>>m>>k,a[1]=1,a[n]=2,q.push(1);
	for(int i=1;i<=n;i++)
		cin>>x;
	for(int i=1;i<=m;i++){
		cin>>x>>y,e[x].push_back(y),e[y].push_back(x);
		if(x==1&&y==n||x==n&&y==1){
			if(n==2&&k==1)
				cout<<"impossible\n",exit(0);
			if(k>1)
				cout<<string(k-1,'N')<<string(n-k,'S')<<"N\n",exit(0);
			cout<<string(k-1,'S')<<string(n-k,'N')<<"S\n",exit(0);
		}
	}
	if(!k)
		cout<<string(n,'S')<<'\n',exit(0);
	while(q.size()&&k>1){
		x=q.front(),q.pop();
		for(int y:e[x])
			if(!a[y])
				a[y]=1,q.push(y),k--;
	}
	for(int i=1;i<=n;i++)
		cout<<(a[i]==1?'N':'S');
	cout<<'\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 7ms
memory: 28532kb

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: 0ms
memory: 29892kb

input:

2 1 2
6124 7094
2 1

output:

NN

result:

ok accepted

Test #4:

score: 0
Accepted
time: 0ms
memory: 28780kb

input:

2 1 1
6901 1417
2 1

output:

impossible

result:

ok accepted

Test #5:

score: -100
Wrong Answer
time: 7ms
memory: 29084kb

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:

NNNNNNNNNSNNNSNNNNNSSSSSSSSNNSNSSNSSNSNSSNNNSSSNSS

result:

wrong answer number of N:s not equal to k