QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#226038 | #6422. Evil Coordinate | kokomiisbest | WA | 25ms | 3852kb | C++14 | 2.0kb | 2023-10-25 15:00:08 | 2023-10-25 15:00:08 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
string s;
int x,y;
const int N = 1e5+10;
int a[4];
void solve(){
cin>>x>>y;
cin>>s;
memset(a,0,sizeof a);
for(int i=0;i<s.size();i++){
if(s[i]=='U') a[0]++;
else if(s[i]=='D') a[1]++;
else if(s[i]=='L') a[2]++;
else a[3]++;
}
int tx=a[3]-a[2],ty=a[0]-a[1];
// cout<<"aaa"<<tx<<" "<<ty<<endl;
//\xc6\xf0\xb5\xe3\xd3\xd0ը\xb5\xafֱ\xbd\xd3\xcc\xd8\xc5м\xb4\xbf\xc9
if(x==0&&y==0){
cout<<"Impossible"<<endl;
return;
}
//\xc8\xe7\xb9\xfb\xd6յ\xe3\xd3\xd0ը\xb5\xaf\xa3\xac\xb2\xbb\xbf\xc9\xc4ܱܿ\xaa
if(tx==x&&ty==y){
cout<<"Impossible"<<endl;
return;
}
//\xb5\xa5\xd0г\xcc·\xa3\xac\xc6\xf0\xb5\xe3\xba\xcd\xd6յ\xe3֮\xbc\xe4\xd3\xd0ը\xb5\xaf\xa3\xacҲ\xb2\xbb\xbfɱ\xdc\xc3\xe2
if((a[0]==0&&a[1]==0)||(a[2]==0&&a[3]==0)){
if(x==0){
if((0<=y&&y<=ty)||(ty<=y&&y<=0)){
cout<<"Impossible"<<endl;
return;
}
}
if(y==0){
if((0<=x&&x<=tx)||(tx<=x&&x<=0)){
cout<<"Impossible"<<endl;
return ;
}
}
}
//\xc6\xe4\xcb\xfb\xc7\xe9\xbf\xf6\xa3\xac\xba\xcf\xc0\xed\xb9\xe6\xb1\xdcը\xb5\xaf\xbc\xb4\xbf\xc9 \xcf\xc8\xd7ߵ\xbd\xd6յ\xe3\xb5\xc4\xd0\xd0/\xc1У\xac\xb1\xa3֤\xb2\xbb\xba\xcdը\xb5\xaf\xd4\xdaһ\xcc\xf5\xcf\xb4\xbf\xc9
if(x==tx||y==0){
while(a[0]--){
cout<<'U';
}
while(a[1]--){
cout<<'D';
}
while(a[2]--){
cout<<'L';
}
while(a[3]--){
cout<<'R';
}
}else if(x==0||y==ty){
while(a[2]--){
cout<<'L';
}
while(a[3]--){
cout<<'R';
}
while(a[0]--){
cout<<'U';
}
while(a[1]--){
cout<<'D';
}
}else{
while(a[0]--){
cout<<'U';
}
while(a[1]--){
cout<<'D';
}
while(a[2]--){
cout<<'L';
}
while(a[3]--){
cout<<'R';
}
}
cout<<endl;
}
int main(){
int t;
cin>>t;
while(t--){
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3652kb
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: 25ms
memory: 3852kb
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 RRUUUUUUD DDLRRRR UD Impossible LLLLRRDD LLRRUDDD Impossible UUDDDDLLR LL Impossible UUUDLRR Impossible Impossible Impossible LLLLLRRRDD Impossible LR Impossible Impossible Impossible Impossible Impossible LLLRRRRRUU UDLLL Impossible UUUDDDL UUDDRR Impossi...
result:
wrong answer case 165, participant's output goes through forbidden coordinate