QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#201726 | #1774. Customs Controls | LDM | WA | 1ms | 7804kb | C++14 | 1.4kb | 2023-10-05 16:27:55 | 2023-10-05 16:27:55 |
Judging History
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]);
}
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(n==2&&k==1){
printf("impossible");
return 0;
}
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
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 7804kb
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