QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#644552 | #6422. Evil Coordinate | rush-from-behind# | WA | 30ms | 3664kb | C++17 | 1.9kb | 2024-10-16 14:34:43 | 2024-10-16 14:34:58 |
Judging History
answer
#include <bits/stdc++.h>
#define F(i,x,y) for(int i=(x);i<=(y);i++)
#define DF(i,x,y) for(int i=(x);i>=(y);i--)
#define ms(x,y) memset(x,y,sizeof(x))
#define SZ(x) (int)x.size()-1
#define all(x) x.begin(),x.end()
#define pb push_back
using namespace std;
typedef long long LL;
typedef unsigned long long ull;
typedef pair<int,int> pii;
template<typename T> void chkmax(T &x,T y){ x=max(x,y);}
template<typename T> void chkmin(T &x,T y){ x=min(x,y);}
template<typename T> void read(T &FF){
FF=0;int RR=1;char ch=getchar();
for(;!isdigit(ch);ch=getchar()) if(ch=='-') RR=-1;
for(;isdigit(ch);ch=getchar()) FF=(FF<<1)+(FF<<3)+ch-48;
FF*=RR;
}
int c[4];
int ord[4];
int fx[4][2]={{0,1},{0,-1},{-1,0},{1,0}};
char dy[4]={'U','D','L','R'};
void work(){
int mx,my;cin>>mx>>my;
string opt;cin>>opt;
ms(c,0);
F(i,0,SZ(opt)){
if(opt[i]=='U') c[0]++;
if(opt[i]=='D') c[1]++;
if(opt[i]=='L') c[2]++;
if(opt[i]=='R') c[3]++;
}
int tx=c[3]-c[2],ty=c[0]-c[1];
if(tx==mx&&ty==my){ cout<<"Impossible"<<'\n';return;}
if(!mx&&!my){ cout<<"Impossible"<<'\n';return;}
bool fl=0;
if(my==ty){
fl=0;
if(!my) fl=1;
}
else if(mx==tx){
fl=1;
if(!mx) fl=0;
}
else fl=0;
if(!fl){
if(ty>=my) ord[0]=3,ord[2]=2;
else ord[0]=2,ord[2]=3;
if(tx>=mx) ord[1]=0,ord[3]=1;
else ord[1]=1,ord[3]=0;
}
else{
if(tx>=mx) ord[0]=0,ord[2]=1;
else ord[0]=1,ord[2]=0;
if(ty>=my) ord[1]=3,ord[3]=2;
else ord[1]=2,ord[3]=3;
}
int x=0,y=0;
F(i,0,3)
F(j,1,c[ord[i]]){
x+=fx[ord[i]][0],y+=fx[ord[i]][1];
if(x==mx&&y==my){ cout<<"Impossible"<<'\n';return;}
}
F(i,0,3) F(j,1,c[ord[i]]) cout<<dy[ord[i]];
cout<<'\n';
}
int main(){
int T;cin>>T;
while(T--) work();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3640kb
input:
5 1 1 RURULLD 0 5 UUU 0 3 UUU 0 2 UUU 0 0 UUU
output:
RRDLLUU UUU Impossible Impossible Impossible
result:
ok 5 cases
Test #2:
score: -100
Wrong Answer
time: 30ms
memory: 3664kb
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:
DDRRUU RUU Impossible Impossible Impossible RRUUUUUUD LRRRRDD DU Impossible RRDDLLLL RRDDDLLU Impossible UULLDDDDR LL Impossible UUULDRR Impossible Impossible Impossible Impossible Impossible RL Impossible Impossible Impossible Impossible Impossible RRRRRUULLL ULLLD Impossible UUUDDDL UURRDD Impossi...
result:
wrong answer case 20, participant does not find an answer but the jury does