QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#612338 | #6422. Evil Coordinate | pugong# | WA | 10ms | 3836kb | C++20 | 1.0kb | 2024-10-05 10:34:26 | 2024-10-05 10:34:30 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=200010;
void solve(){
int mx,my,xx=0,yy=0;
string s;
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++;
}
if(mx>=0&&my>=0){
if(xx>=mx&&yy>=my) cout<<"Impossible\n";
else cout<<string(a[2],'D')<<string(a[3],'L')<<string(a[1],'U')<<string(a[4],'R')<<"\n";
}
else if(mx<=0&&my>=0){
if(xx<=mx&&yy>=my) cout<<"Impossible\n";
else cout<<string(a[2],'D')<<string(a[4],'R')<<string(a[1],'U')<<string(a[3],'L')<<"\n";
}
else if(mx<=0&&my<=0){
if(xx<=mx&&yy<=my) cout<<"Impossible\n";
else cout<<string(a[4],'R')<<string(a[1],'U')<<string(a[2],'D')<<string(a[3],'L')<<"\n";
}
else{
if(xx>=mx&&yy<=my) cout<<"Impossible\n";
else cout<<string(a[1],'U')<<string(a[2],'D')<<string(a[3],'L')<<string(a[4],'R')<<"\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: 3552kb
input:
5 1 1 RURULLD 0 5 UUU 0 3 UUU 0 2 UUU 0 0 UUU
output:
DLLUURR UUU Impossible Impossible Impossible
result:
ok 5 cases
Test #2:
score: -100
Wrong Answer
time: 10ms
memory: 3836kb
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:
DDUURR UUR Impossible Impossible Impossible DRRUUUUUU DDRRRRL DU Impossible DDLLLLRR UDDDLLRR Impossible DDDDRUULL LL Impossible DLUUURR DDDDDDDUUU Impossible Impossible Impossible Impossible RL D L DDDDLUURRR DLUU Impossible Impossible UDLLL Impossible DDDUUUL UUDDRR Impossible DDRRUUL DDUUUUURR RR...
result:
wrong answer case 17, participant's output goes through forbidden coordinate