QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#58713#1774. Customs Controlsdream_harrasserWA 2ms3664kbC++1.0kb2022-10-27 15:07:282022-10-27 15:07:33

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-27 15:07:33]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3664kb
  • [2022-10-27 15:07:28]
  • 提交

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