QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#202011 | #1774. Customs Controls | wert | WA | 1ms | 5908kb | C++14 | 1.4kb | 2023-10-05 18:22:59 | 2023-10-05 18:23:00 |
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] = 'U';
} else ch[0] = ch[n - 1] = 'P';
for(int i = 0;i < n;i++){
if(ch[i] == '.'){
if(k){
ch[i] = 'U';
k--;
} else ch[i] = 'P';
}
}
}else{
ch[0] = 'U';
k--;
for(int i = head[1];i && k;i = ed[i].next){
int v = ed[i].to;
ch[v - 1] = 'U';
}for(int i = 0;i < n;i++) if(ch[i] == '.') ch[i] = 'P';
}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
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5908kb
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:
UPPPU
result:
wrong answer invalid character