QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#612653#6422. Evil Coordinatepugong#WA 11ms3736kbC++201.2kb2024-10-05 12:27:562024-10-05 12:28:00

Judging History

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

  • [2024-10-05 12:28:00]
  • 评测
  • 测评结果:WA
  • 用时:11ms
  • 内存:3736kb
  • [2024-10-05 12:27:56]
  • 提交

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]++,yy++;
		if(i=='D') a[2]++,yy--;
		if(i=='L') a[3]++,xx--;
		if(i=='R') a[4]++,xx++;
	}
	// cout<<a[1]<<" "<<a[2]<<" "<<a[3]<<" "<<a[4]<<"\n";
	if(mx==0&&my==0){
		cout<<"Impossible\n";
		return ;
	}
	if(yy!=my){
		if(my>0) str+=string(a[2],'D')+string(a[1],'U');
		else 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{
		if(mx>0) str+=string(a[3],'L')+string(a[4],'R');
		else str+=string(a[4],'R')+string(a[3],'L');
		if(my>0) str+=string(a[2],'D')+string(a[1],'U');
		else str+=string(a[1],'U')+string(a[2],'D');
	}
	xx=yy=0;
	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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

LLRRDUU
UUU
Impossible
Impossible
Impossible

result:

ok 5 cases

Test #2:

score: -100
Wrong Answer
time: 11ms
memory: 3736kb

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
RRDUUUUUU
DDRRRRL
UD
Impossible
LLLLRRDD
LLRRUDDD
Impossible
UUDDDDRLL
LL
Impossible
DUUULRR
Impossible
Impossible
Impossible
RRRLLLLLDD
Impossible
RL
Impossible
Impossible
Impossible
Impossible
Impossible
RRRRRLLLUU
UDLLL
Impossible
LUUUDDD
UUDDRR
Impossi...

result:

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