QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#666934 | #6422. Evil Coordinate | wane718 | WA | 15ms | 3964kb | C++14 | 3.4kb | 2024-10-22 20:28:12 | 2024-10-22 20:28:18 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define FASTIO ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
char a[5]={'0','L','R','U','D'};
int b[5]={0,-1,+1,+1,-1};
void solve()
{
int dx,dy;cin>>dx>>dy;
int sx=0,sy=0,ex=0,ey=0;
string s;cin>>s;
int x=0,y=0;
int n=s.size();
map<char,int>mp;
for(int i=0;i<n;i++)
{
mp[s[i]]++;
if(s[i]=='U')
y++;
else if(s[i]=='D')
y--;
else if(s[i]=='L')
x--;
else
x++;
}
if(dx==0&&dy==0||x==dx&&y==dy)
{
cout<<"Impossible"<<endl;
return;
}
for(int i=1;i<=4;i++)
{
for(int j=1;j<=4;j++)
{
for(int k=1;k<=4;k++)
{
for(int z=1;z<=4;z++)
{
if(i!=j&&i!=k&&i!=z&&j!=k&&j!=z&&k!=z)
{
sx=0,sy=0,ex=0,ey=0;
if(i<3)
ex+=mp[a[i]]*b[i];
else
ey+=mp[a[i]]*b[i];
//cout<<sx<<" "<<sy<<endl;
//cout<<ex<<" "<<ey<<endl;
if((ex<=dx&&dx<=sx&&dy==ey&&i<3)||(sx<=dx&&dx<=ex&&dy==ey&&i<3)||(i>=3&&dx==ex&&dy>=sy&&dy<=ey)||(i>=3&&dx==ex&&dy>=ey&&dy<=sy))
{
continue;
}
sx=ex,sy=ey;
if(j<3)
ex+=mp[a[j]]*b[j];
else
ey+=mp[a[j]]*b[j];
if((ex<=dx&&dx<=sx&&dy==ey&&j<3)||(ex<=dx&&dx<=sx&&dy==ey&&j<3)||(j>=3&&dx==ex&&dy>=sy&&dy<=ey)||(j>=3&&dx==ex&&dy>=ey&&dy<=sy))
{
continue;
}
sx=ex,sy=ey;
if(k<3)
ex+=mp[a[k]]*b[k];
else
ey+=mp[a[k]]*b[k];
if((ex<=dx&&dx<=sx&&dy==ey&&k<3)||(sx<=dx&&dx<=ex&&dy==ey&&k<3)||(k>=3&&dx==ex&&dy>=sy&&dy<=ey)||(k>=3&&dx==ex&&dy>=ey&&dy<=sy))
{
continue;
}
sx=ex,sy=ey;
if(z<3)
ex+=mp[a[z]]*b[z];
else
ey+=mp[a[z]]*b[z];
if((ex<=dx&&dx<=sx&&dy==ey&&z<3)||(sx<=dx&&dx<=ex&&dy==ey&&z<3)||(z>=3&&dx==ex&&dy>=sy&&dy<=ey)||(z>=3&&dx==ex&&dy>=ey&&dy<=sy))
{
continue;
}
for(int o=1;o<=mp[a[i]];o++)
cout<<a[i];
for(int o=1;o<=mp[a[j]];o++)
cout<<a[j];
for(int o=1;o<=mp[a[k]];o++)
cout<<a[k];
for(int o=1;o<=mp[a[z]];o++)
cout<<a[z];
cout<<endl;
return;
}
}
}
}
}
cout<<"Impossible"<<endl;
}
signed main()
{
FASTIO;
int t;cin>>t;
while(t--)
solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3472kb
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: 15ms
memory: 3964kb
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:
RRUUDD RUU Impossible Impossible Impossible RRUUUUUUD LRRRRDD UD Impossible LLLLRRDD LLRRUDDD Impossible RUUDDDDLL LL Impossible LRRUUUD Impossible Impossible Impossible LLLLLRRRDD Impossible LR Impossible Impossible Impossible Impossible Impossible LLLRRRRRUU LLLUD Impossible LUUUDDD RRUUDD Impossi...
result:
wrong answer case 116, participant's output goes through forbidden coordinate