QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#63327 | #1774. Customs Controls | Never | WA | 1ms | 3284kb | C++14 | 1.4kb | 2022-11-21 18:47:40 | 2022-11-21 18:47:43 |
Judging History
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