QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#612574#6422. Evil Coordinatepugong#WA 7ms3788kbC++201.0kb2024-10-05 12:06:372024-10-05 12:06:37

Judging History

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

  • [2024-10-05 12:06:37]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:3788kb
  • [2024-10-05 12:06:37]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=200010;

void solve(){
	int mx,my,xx=0,yy=0,cnt=0;
	string s,str;
	vector<int> a(10);
	cin>>mx>>my>>s;
	for(char i:s){
		if(i=='U') a[1]++;
		if(i=='D') a[2]++;
		if(i=='L') a[3]++;
		if(i=='R') a[4]++;
	}
	// cout<<a[1]<<" "<<a[2]<<" "<<a[3]<<" "<<a[4]<<"\n";
	if(mx==0&&my==0){
		cout<<"Impossible\n";
		return ;
	}
	if(mx!=0){
		str=string(a[1],'U')+string(a[2],'D');
		if(mx>0) str+=string(a[3],'L')+string(a[4],'R');
		else str+=string(a[4],'R')+string(a[3],'L');
	}
	else{
		str=string(a[3],'L')+string(a[4],'R');
		if(my>0) str+=string(a[2],'D')+string(a[1],'U');
		else str+=string(a[1],'U')+string(a[2],'D');
	}
	for(char i:str){
		if(i=='U') yy++;
		if(i=='D') yy--;
		if(i=='L') xx--;
		if(i=='R') xx++;
		if(xx==mx&&yy==my) cnt=1;	
	}
	if(cnt) cout<<"Impossible\n";
	else cout<<str<<"\n";
}

int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int T=1;
	cin>>T;
	while(T--){
		solve();
	}
	return 0;
}

詳細信息

Test #1:

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

input:

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

output:

UUDLLRR
UUU
Impossible
Impossible
Impossible

result:

ok 5 cases

Test #2:

score: -100
Wrong Answer
time: 7ms
memory: 3788kb

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:

UUDDRR
UUR
Impossible
Impossible
Impossible
UUUUUUDRR
DDRRRRL
UD
Impossible
DDLLLLRR
UDDDLLRR
Impossible
UUDDDDRLL
LL
Impossible
UUUDLRR
Impossible
Impossible
Impossible
LLLLLRRRDD
Impossible
RL
Impossible
Impossible
Impossible
Impossible
Impossible
LLLRRRRRUU
UDLLL
Impossible
UUUDDDL
UUDDRR
Impossi...

result:

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