QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#505923 | #6422. Evil Coordinate | MOUZ_donk | WA | 28ms | 3756kb | C++20 | 1.8kb | 2024-08-05 13:39:59 | 2024-08-05 13:39:59 |
Judging History
answer
#include<bits/stdc++.h>
const int N=1e3+10;
const int M=2e6+10;
#define int long long
typedef double db;
typedef long long ll;
using namespace std;
using pii = pair<int,int>;
#define up(i,a,b) for(int i=(a);i<=(b);++i)
#define down(i,a,b) for(int i=(a);i>=(b);--i)
#define puts(a) (cout<<a<<endl)
#define inf (0x7fffffff)
const int MOD=100003;
int xx,yy;
int d[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
int u[4];
int a[]={0,1,2,3};
bool check(){
int aa=0,bb=0;
//aa行,bb列
for(int i=0;i<4;i++){
for(int j=0;j<u[a[i]];j++){
aa+=d[a[i]][0];
bb+=d[a[i]][1];
if(aa==xx&&bb==yy)
return false;
}
}
return true;
}
void solve(){
string s;
cin>>xx>>yy;
int x=0,y=0;
int flag=0;
// if(xx==0&&yy==0){
// cout<<"Impossible"<<endl;
// flag=1;
//
//
// }
cin>>s;
// if(flag)
// return ;
memset(u,0,sizeof u);
if(x==xx&&y==yy){
cout<<"Impossible"<<endl;
return ;
}
for(int i=0;s[i];i++){
if(s[i]=='U')u[0]++,y++;
else if(s[i]=='D')
u[1]++,x++;
else if(s[i]=='R')
u[2]++,y--;
else if(s[i]=='L')
u[3]++,x--;
}
if(x==xx&&y==yy){
cout<<"Impossible"<<endl;
return ;
}
int ok=1;
for(int i=1;i<24;i++){
if(check()){
for(int i=0;i<4;i++){
for(int j=0;j<u[a[i]];j++){
if(a[i]==0)
cout<<"U";
else if(a[i]==1)
cout<<"D";
else if(a[i]==2)
cout<<"R";
else if(a[i]==3)
cout<<"L";
}
}
ok=0;
break;
}
next_permutation(a,a+4);
}
if(ok){
cout<<"Impossible";
}
cout<<endl;
}
signed main() {
int T;
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
T=1;
cin>>T;
while(T--)
solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3580kb
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: 28ms
memory: 3756kb
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 RRDUUUUUU LRRRRDD DU Impossible LLLLRRDD LLRRDDDU Impossible UUDDDDRLL LL Impossible LRRDUUU Impossible Impossible Impossible LLLLLRRRDD Impossible LR Impossible Impossible Impossible Impossible Impossible LLLRRRRRUU LLLDU Impossible LDDDUUU DDUURR Impossi...
result:
wrong answer case 1190, participant does not find an answer but the jury does