QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#764839 | #3308. Remote Control | reverSilly | WA | 44ms | 6048kb | C++23 | 1.9kb | 2024-11-20 10:53:32 | 2024-11-20 10:53:40 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
constexpr int mxn{50000};
struct Point{
int x,y;
void execute(char op)
{
if(op=='L')
if(pair{x,y}!=pair{1,0})
--x;
if(op=='R')
if(pair{x,y}!=pair{-1,0})
++x;
if(op=='U')
if(pair{x,y}!=pair{0,-1})
++y;
if(op=='D')
if(pair{x,y}!=pair{0,1})
--y;
}
};
struct minipoint{
int8_t x,y;
minipoint(Point p):
x{p.x},y{p.y}{}
minipoint()=default;
operator Point()const
{
return {x,y};
}
};
int abs(Point p)
{
return abs(p.x)+abs(p.y);
}
int N,Q,blen;
int b(int i)
{
return i/blen;
}
int bn()
{
return (N-1)/blen+1;
}
string S;
Point execute(Point ini,int L,int R)
{
for(int i=L;i<R;++i)
{
ini.execute(S[i]);
// cerr<<S[i]<<' '<<ini.x<<' '<<ini.y<<'\n';
}
return ini;
}
minipoint &trans(int i,Point p)
{
static array<array<minipoint,60>,60>m_trans[mxn];
return m_trans[i][p.x+50][p.y+50];
}
Point dt[mxn];
int main()
{
cin.tie(nullptr);
ios::sync_with_stdio(false);
cin>>N
>>S;
blen=round(pow(N,0.333333333));
cerr<<"blen="<<blen<<'\n';
for(int i=0;i<bn();++i)
{
Point ini;
for(ini.x=-blen;ini.x<=blen;++ini.x)
{
for(ini.y=-blen;ini.y<=blen;++ini.y)
{
if(abs(ini)<=blen)
{
trans(i,ini)=execute(ini,i*blen,min(N,i*blen+blen));
// cerr<<"trans "<<trans(i,ini).x<<' '<<trans(i,ini).y<<'\n';
}
}
}
dt[i]={100000,0};
dt[i]=execute(dt[i],i*blen,min(N,i*blen+blen));
dt[i].x-=100000;
}
cin>>Q;
for(int i=0;i<Q;++i)
{
Point p;
cin>>p.x>>p.y;
for(int i=0;i<bn();++i)
{
if(abs(p)>blen)
{
p.x+=dt[i].x;
p.y+=dt[i].y;
// cerr<<"dt "<<dt[i].x<<' '<<dt[i].y<<'\n';
}
else
p=trans(i,p);
// cerr<<p.x<<' '<<p.y<<'\n';
}
cout<<p.x<<' '<<p.y<<'\n';
}
return 0;
}
// 8
// RRDRUULL
// 5
// -2 1
// -2 2
// -2 -1
// -3 -1
// 1 1
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 6048kb
input:
8 RRDRUULL 5 -2 1 -2 2 -2 -1 -3 -1 1 1
output:
-1 3 -1 3 1 0 -2 -1 2 2
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 1ms
memory: 3888kb
input:
8 LLDDRRUU 18 1 1 1 2 1 3 2 1 2 2 2 3 3 1 3 2 3 3 1 1 1 2 1 3 2 1 2 2 2 3 3 1 3 2 3 3
output:
1 1 -1 2 1 3 2 3 2 3 2 3 3 1 3 2 3 3 1 1 -1 2 1 3 2 3 2 3 2 3 3 1 3 2 3 3
result:
ok 18 lines
Test #3:
score: 0
Accepted
time: 2ms
memory: 4504kb
input:
1000 ULRULRURDDDLURUURULUDRDDRDLURRRUDDDDDURURUDDDRLLDURDDDLLDLULUURDRRDDDURDDRLRULDLUULDLRDLURUUUUDDRULDRRUDDDDUUULLURDUUUULDLDDUUUDUUUUDDLURLUDDDUDLDLRRUDURDRDLRURLUULDRLRDRDDRDRRDLUUURURLRLDUDLDLRURLURUDRRULDRDDRUDDDRURDRRDLDLRDLRDUDDLLLLRUULRRUDURUUUDDDLRDRDRDRURUDDURUDLRLDLLDDULURDURDLLLUULLDLD...
output:
-105 -4 17 -30 41 80 6 -100 23 28 10 -58 -22 -34 1 24 -46 -79 -43 87 -102 -76 85 25 -42 -3 -71 36 -55 -109 -39 -105 5 -102 82 15 42 -22 81 63 -64 -7 -82 -62 74 9 -41 37 21 18 -109 -38 51 48 10 -46 -37 28 -18 -110 -67 -74 -96 -55 -5 16 -49 -21 -81 -56 -106 27 62 48 21 59 -79 72 4 29 17 -65 87 44 72 1...
result:
ok 1000 lines
Test #4:
score: -100
Wrong Answer
time: 44ms
memory: 3908kb
input:
300000 DDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURULDDLURU...
output:
1 0 1 1 1 2 4 0 4 1 4 2 7 0 7 1 7 2 10 0 10 1 10 2 13 0 13 1 13 2 16 0 16 1 16 2 19 0 19 1 19 2 22 0 22 1 22 2 25 0 25 1 25 2 28 0 28 1 28 2 31 0 31 1 31 2 34 0 34 1 34 2 37 0 37 1 37 2 40 0 40 1 40 2 43 0 43 1 43 2 46 0 46 1 46 2 49 0 49 1 49 2 52 0 52 1 52 2 55 0 55 1 55 2 58 0 58 1 58 2 61 0 61 1...
result:
wrong answer 1st lines differ - expected: '1 -1', found: '1 0'