QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#226033#6422. Evil CoordinatekokomiisbestWA 33ms3540kbC++142.0kb2023-10-25 14:53:172023-10-25 14:53:17

Judging History

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

  • [2023-10-25 14:53:17]
  • 评测
  • 测评结果:WA
  • 用时:33ms
  • 内存:3540kb
  • [2023-10-25 14:53:17]
  • 提交

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(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
  
    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: 1ms
memory: 3404kb

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: 33ms
memory: 3540kb

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 61, participant does not find an answer but the jury does