QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#58713 | #1774. Customs Controls | dream_harrasser | WA | 2ms | 3664kb | C++ | 1.0kb | 2022-10-27 15:07:28 | 2022-10-27 15:07:33 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int n, m, K, P, U;
int F[100010], T[100010];
char s[100010];
void c(int u, bool ty)
{
s[u] = ty ? 'U':'P';
if(ty)
U--;
else
P--;
}
int main()
{
scanf("%d%d%d", &n, &m, &U);
P = n - U;
for(int i = 1; i <= n; i++)
{
int w;
scanf("%d", &w);
}
for(int i=1;i<=m;i++)
{
int u, v;
scanf("%d%d", &u, &v);
if(u > v)
swap(u, v);
if(u == 1)
T[v] = 1;
if(v == n)
F[u] = 1;
}
if(T[n])
{
if(P == 1 && U == 1)
{
puts("impossible");
return 0;
}
if(P >= 2)
c(1, 0), c(n, 0);
else
c(1, 1), c(n, 1);
for(int i = 2; i < n; i++)
c(i, U);
}
else
{
vector<int> A(1, 1), B(1, n);
for(int i = 2; i < n; i++)
((T[i] && !F[i]) ? A : B).push_back(i);
reverse(B.begin(), B.end());
int w = (A.size() > B.size()) ^ (U < P);
A.insert(A.end(), B.begin(), B.end());
if(w)
reverse(A.begin(), A.end());
for(int i = 1; i <= n; i++)
c(A[i - 1], U);
}
puts(s + 1);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3664kb
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:
PUUPP
result:
wrong answer invalid character