QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#201730#1774. Customs ControlsLDMWA 0ms7864kbC++141.4kb2023-10-05 16:28:352023-10-05 16:28:35

Judging History

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

  • [2023-10-05 16:28:35]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:7864kb
  • [2023-10-05 16:28:35]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
namespace ldm{
	int n,m,k,t[100001],h[100001],cnt,d[3][100001],v[100001],x[200001],y[200001],rd[100001],pd[100001],ans[100001];
	struct qx{
		int to,next;
	}a[400001];
	void hb(int x,int y){
		cnt++;
		a[cnt].to=y;
		a[cnt].next=h[x];
		h[x]=cnt;
	}
	queue<int> q;
	int main(){
		scanf("%d%d%d",&n,&m,&k);
		for(int i=1;i<=n;i++){
			scanf("%d",&t[i]);
		}
		if(n==2&&k==1){
			printf("impossible");
			return 0;
		}
		for(int i=1;i<=m;i++){
			scanf("%d%d",&x[i],&y[i]);
			if((x[i]==1&&y[i]==n)||(x[i]==n&&y[i]==1)){
				if(k>=2){
					int cc=1;
					printf("N");
					k--;
					for(int i=1;i<=k-1;i++){
						cc++;
						printf("N");
					}
					for(int i=1;i<=n-cc;i++){
						printf("S");
					}
					printf("N");
					return 0;
				}else{
					printf("S");
					for(int i=1;i<=k;i++){
						printf("N");
					}
					for(int i=1;i<=n-1-k;i++){
						printf("S");
					}
					return 0;
				}
			}
			hb(x[i],y[i]);
			hb(y[i],x[i]);
		}
		q.push(1);
		while(!q.empty()){
			int x=q.front();
			q.pop();
			if(v[x]) continue;
			if(!k) break;
			ans[x]=v[x]=1;
			k--;
			for(int i=h[x];i!=0;i=a[i].next){
				int y=a[i].to;
				q.push(y);
			}
		}
		for(int i=1;i<=n;i++){
			if(ans[i]){
				printf("N");
			}else{
				printf("S");
			}
		}
		return 0;
	}
}
int main(){
	ldm::main();
	return 0;
}
//8m 1024m

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 7864kb

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:

NSSSSN

result:

wrong answer invalid output length