QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#506194#6422. Evil Coordinate122WA 15ms3856kbC++142.4kb2024-08-05 15:54:392024-08-05 15:54:39

Judging History

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

  • [2024-08-05 15:54:39]
  • 评测
  • 测评结果:WA
  • 用时:15ms
  • 内存:3856kb
  • [2024-08-05 15:54:39]
  • 提交

answer

#include <iostream> 
#include<vector>
#include<string>
#include<algorithm>
#include <cstring>
#include<ctype.h>
#include<set>
#include<map>
#include<cmath>
#include<climits>
#include<stack>
#include<list>
#include<queue>
#include<unordered_map>
#include<unordered_set>
#define IOS ios::sync_with_stdio(false);cin.tie(0); 
#define maxn 100+5
#define ll long long
using namespace std;
const int mod = 1e8;


signed main() {
	int t;
	cin >> t;
	string s = "UDLR";
	while (t--)
	{
		int x, y;
		vector<int>cnt(5, 0);
		cin >> x >> y;
		string str;
		cin >> str;

		for (int i = 0; i < str.size(); i++)
		{
			if (str[i] == s[0])
				cnt[0]++;
			if (str[i] == s[1])
				cnt[1]++;
			if (str[i] == s[2])
				cnt[2]++;
			if (str[i] == s[3])
				cnt[3]++;
		}
		int up = cnt[0]; int down = cnt[1]; int left = cnt[2]; int right = cnt[3];
		down = -down; left = -left;
		bool flag1 = true;
		bool flag2 = true;
		int len = str.size();
		int a = 0;
		int b = 0;
		string path;
		if (x == 0 && y == 0)
		{
			cout << "Impossible"<<endl;
			continue;
		}
		if (up + down == y&&left+right==x)
		{
			cout << "Impossible"<<endl;
			continue;
		}
		if (up >= y && down == 0 && left == 0 && right == 0 ||
			(down <= y && up == 0 && left == 0 && right == 0) ||
			(left <= x && down == 0 && up == 0 && right == 0) ||
			(right >=x && up == 0 && down == 0 && left == 0))
		{
			cout << "Impossible" << endl;
			continue;
		}
		if (up + down >= y && left==0&&right==0&&x==0||(left+right>=x&&up==0&&down==0&&y==0))
		{
			cout << "Impossible" << endl;
			continue;
		}
		/*cout << up << " " << down << endl;*/
		if (up + down != y)
		{
			while (up)
			{
				up--;
				path.push_back(s[0]);
			}
			while (down<0)
			{
				down++;
				path.push_back(s[1]);
			}
			while (left<0)
			{
				left++;
				path.push_back(s[2]);
			}
			while (right)
			{
				right--;
				path.push_back(s[3]);
			}
			cout << path << endl;
			continue;
		}
		
		if (left + right != x)
		{
			while (left < 0)
			{
				left++;
				path.push_back(s[2]);
			}
			while (right)
			{
				right--;
				path.push_back(s[3]);
			}
			while (up)
			{
				up--;
				path.push_back(s[0]);
			}
			while (down < 0)
			{
				down++;
				path.push_back(s[1]);
			}

			cout << path << endl;
			continue;
		}
		else cout << "Impossible" << endl;

	}


}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3508kb

input:

5
1 1
RURULLD
0 5
UUU
0 3
UUU
0 2
UUU
0 0
UUU

output:

LLRRUUD
UUU
Impossible
Impossible
Impossible

result:

ok 5 cases

Test #2:

score: -100
Wrong Answer
time: 15ms
memory: 3856kb

input:

11109
6 0
RUDUDR
2 0
URU
0 0
UDRU
0 0
R
-1 1
LDUUDDRUUL
-1 5
RRUUUDUUU
-8 4
RRDRLDR
2 0
UD
0 0
UUDD
3 -2
LDDLLLRR
3 -2
LDRURLDD
1 0
RRL
-1 0
DUDDLLRDU
-4 0
LL
-1 -1
DLRLDLUDUR
1 4
URDULUR
0 0
DDUUDUDDDD
0 2
UU
1 0
RRULD
0 -2
LDLRLLDRRL
0 1
RLRLLRLUR
-3 0
RL
0 0
D
0 0
L
0 0
DDLRRUDRUD
0 0
DULU
2 0
RR...

output:

RRUUDD
UUR
Impossible
Impossible
Impossible
RRUUUUUUD
DDLRRRR
UD
Impossible
LLLLRRDD
LLRRUDDD
Impossible
UUDDDDLLR
Impossible
Impossible
UUUDLRR
Impossible
Impossible
Impossible
LLLLLRRRDD
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
LLLRRRRRUU
UDLLL
Impossible
LUUUDD...

result:

wrong answer case 14, participant does not find an answer but the jury does