QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#226019#6422. Evil CoordinatekokomiisbestWA 26ms3772kbC++141.9kb2023-10-25 14:40:462023-10-25 14:40:46

Judging History

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

  • [2023-10-25 14:40:46]
  • 评测
  • 测评结果:WA
  • 用时:26ms
  • 内存:3772kb
  • [2023-10-25 14:40:46]
  • 提交

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]++;
    }	
    //\xc8\xe7\xb9\xfb\xd6յ\xe3\xd3\xd0ը\xb5\xaf\xa3\xac\xb2\xbb\xbf\xc9\xc4ܱܿ\xaa
    if((a[0]-a[1])==x&&(a[3]-a[2]==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(abs(y)<=abs(a[1]-a[0])){
                cout<<"Impossible"<<endl;
                return;
            }
        }
        if(y==0){
            if(abs(x)<=abs(a[2]-a[3])){
                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
    int tx=a[0]-a[1],ty=a[3]-a[2];
    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: 3600kb

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: 26ms
memory: 3772kb

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
UUDR
Impossible
UUUUDDDLLR
UUUUUUDRR
DDLRRRR
UD
Impossible
LLLLRRDD
UDDDLLRR
Impossible
UUDDDDLLR
LL
Impossible
UUUDLRR
Impossible
Impossible
UDLRR
LLLLLRRRDD
LLLLRRRRU
LR
Impossible
Impossible
UUDDDDLRRR
UUDL
Impossible
LLLRRRRRUU
UDLLL
Impossible
UUUDDDL
UUDDRR
Impossible
UUDDLRR
RRUUUU...

result:

wrong answer case 3, participant's output goes through forbidden coordinate