QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#202020 | #1774. Customs Controls | wert | WA | 1ms | 7932kb | C++14 | 1.4kb | 2023-10-05 18:30:05 | 2023-10-05 18:30:05 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
namespace ac{
const int MAXN = 1000005, inf = 0x7fffffff / 2;
int n, m, k, u, v, t[MAXN], d1, d2;
int head[MAXN], cnt;
char ch[MAXN];
struct node{
int next, to;
}ed[4 * MAXN];
void add_edge(int u, int v){
ed[++cnt].next = head[u];
ed[cnt].to = v;
head[u] = cnt;
}
int main(){
bool flag = 1;
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", &u, &v);
add_edge(u, v);
add_edge(v, u);
if(u == 1 || v == 1) d1++;
if(u == n || v == n) d2++;
if(u == 1 && v == n || u == n && v == 1) flag = 0;
}for(int _ = 0;_ < n;_++) ch[_] = '.';
if(n == 2 && k == 1){
printf("impossible");
return 0;
}
if(!flag){
if(k >= 2){
k -= 2;
ch[0] = ch[n - 1] = 'N';
} else ch[0] = ch[n - 1] = 'S';
for(int i = 0;i < n;i++){
if(ch[i] == '.'){
if(k){
ch[i] = 'N';
k--;
} else ch[i] = 'S';
}
}
}else{
ch[0] = 'N';
k--;
for(int i = head[1];i && k;i = ed[i].next){
int v = ed[i].to;
ch[v - 1] = 'N';
}for(int i = 0;i < n;i++) if(ch[i] == '.') ch[i] = 'S';
}printf("%s", ch);
return 0;
}
} int main(){
// freopen("data.in", "r", stdin);
//// freopen("ex_data2.in", "r", stdin);
// freopen("data.out", "w", stdout);
return ac::main();
}//6MB
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 7932kb
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: 1ms
memory: 5876kb
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: 5880kb
input:
2 1 2 6124 7094 2 1
output:
NN
result:
ok accepted
Test #4:
score: 0
Accepted
time: 1ms
memory: 7924kb
input:
2 1 1 6901 1417 2 1
output:
impossible
result:
ok accepted
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 7892kb
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:
NNNSSNSSSSSSSSSSSSSSSSSSSSSNSSSSSNSSSSSSSSSSSSSSSS
result:
wrong answer number of N:s not equal to k