QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#226026 | #6422. Evil Coordinate | kokomiisbest | WA | 30ms | 3576kb | C++14 | 1.9kb | 2023-10-25 14:44:52 | 2023-10-25 14:44:52 |
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]++;
}
//\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((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();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3576kb
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: 30ms
memory: 3480kb
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 UUUUDDDLLR UUUUUUDRR DDLRRRR UD Impossible LLLLRRDD UDDDLLRR Impossible UUDDDDLLR LL Impossible UUUDLRR Impossible Impossible UDLRR LLLLLRRRDD LLLLRRRRU LR Impossible Impossible Impossible Impossible Impossible LLLRRRRRUU UDLLL Impossible UUUDDDL UUDDRR Impossible UU...
result:
wrong answer case 5, participant's output goes through forbidden coordinate