QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#645487 | #9469. Chinese Checkers | Afterlife# | AC ✓ | 67ms | 3616kb | C++20 | 3.5kb | 2024-10-16 18:40:03 | 2024-10-16 18:40:04 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
const int N=111;
int len[]={1,2,3,4,13,12,11,10,9,10,11,12,13,4,3,2,1};
int dy[]={0,0,0,4,-1,-1,-1,-1,0,0,0,0,-5,-1,-1,-1,-1};
auto go(string op,int x,int y)
{
if(op.size()==1)
return pii(0,op[0]=='L'?-1:1);
pii ret;
if(op[0]=='L')
{
ret.first=1;
ret.second=dy[x];
if(op[1]=='R')
ret.second++;
}
else
{
ret.first=-1;
if(x)
ret.second=-dy[x-1];
if(op[1]=='L')
ret.second--;
}
return ret;
}
bool ispal(vector<int> v)
{
vector<int> u=v;
reverse(u.begin(),u.end());
return u==v;
}
int main()
{
int n;
vector<vector<int> >beg(17,vector<int> (18,-1));
for(int i=0;i<4;i++)
for(int j=0;j<len[i];j++)
beg[i][j]=0;
for(int i=4;i<8;i++)
for(int j=0;j<=7-i;j++)
beg[i][j]=5,beg[i][len[i]-1-j]=3;
for(int i=9;i<13;i++)
for(int j=0;j<=i-9;j++)
beg[i][j]=2,beg[i][len[i]-1-j]=4;
for(int i=13;i<17;i++)
for(int j=0;j<=17-i;j++)
beg[i][j]=1;
while(cin>>n)
{
auto now=beg;
int r=0;
while(n--)
{
int x,y;
cin>>x>>y;
x--,y--;
string op;
cin>>op;
vector<pii> seq;
seq.push_back({x,y});
int z=now[x][y];
if(r==z)
{
while(1)
{
auto [x,y]=seq.back();
auto [dx,dy]=go(op,x,y);
int tx=x+dx,ty=y+dy;
if(tx<0||tx>=17||ty<0||ty>=len[tx])
break;
seq.push_back({tx,ty});
}
int stp=-1;
for(int i=1;i<seq.size();i++)
{
auto [tx,ty]=seq[i];
if(now[tx][ty]!=-1)
continue;
if(beg[tx][ty]!=-1&&beg[tx][ty]!=r&&(beg[tx][ty]^1)!=r)
continue;
int ok=0;
if(i==1)
ok=1;
else
{
vector<int> v;
for(int j=1;j<i;j++)
{
auto [p,q]=seq[j];
if(now[p][q]!=-1)
v.push_back(1);
else
v.push_back(0);
}
if(*max_element(v.begin(),v.end())!=0)
ok=ispal(v);
}
if(ok)
stp=i;
}
if(stp!=-1)
{
auto [tx,ty]=seq[stp];
swap(now[x][y],now[tx][ty]);
}
}
r=(r+1)%6;
}
for(int i=0;i<6;i++)
{
vector<pii> v;
for(int x=0;x<17;x++)
for(int y=0;y<len[x];y++)
if(now[x][y]==i)
{
v.push_back({x,y});
}
for(int j=0;j<10;j++)
cout<<v[j].first+1<<" "<<v[j].second+1<<" \n"[j+1==10];
}
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3616kb
input:
12 1 1 LL 16 1 UL 10 1 R 5 11 L 11 10 L 7 1 LR 2 2 LR 13 5 UL 12 2 R 5 12 L 11 11 L 6 1 LR
output:
2 1 3 1 3 2 3 3 4 1 4 2 4 3 4 4 5 5 6 9 12 4 14 1 14 2 14 3 14 4 15 1 15 2 15 3 16 2 17 1 10 2 11 1 11 2 12 1 12 3 12 5 13 1 13 2 13 3 13 4 5 7 5 9 5 10 5 13 6 10 6 11 6 12 7 10 7 11 8 10 10 10 11 7 11 9 12 10 12 11 12 12 13 10 13 11 13 12 13 13 5 1 5 2 5 3 5 4 6 2 6 3 7 1 7 2 8 1 11 3
result:
ok 6 lines
Test #2:
score: 0
Accepted
time: 67ms
memory: 3588kb
input:
39 4 1 LR 14 1 UR 13 4 R 6 12 L 13 10 UL 6 2 R 3 1 LL 16 1 UR 13 1 R 6 9 UL 12 12 L 6 4 L 2 1 LL 13 6 R 13 8 UR 6 11 R 10 10 LL 5 2 R 9 1 R 16 2 LL 10 1 UL 5 13 LL 13 13 UL 5 5 R 3 2 UL 17 1 UR 11 8 UL 8 10 LL 13 12 L 6 2 LR 4 2 LL 15 1 LR 11 1 UR 7 11 UL 13 10 UR 8 1 LR 4 4 LR 13 9 UL 13 3 R 39 4 1...
output:
1 1 2 1 2 2 3 1 3 3 4 3 5 6 8 9 9 2 10 2 11 7 12 8 13 7 14 2 14 3 14 4 15 2 15 3 16 1 16 2 9 1 10 1 10 7 11 2 12 1 12 2 12 3 13 2 13 4 13 5 5 9 5 10 5 11 5 12 6 10 6 11 6 12 7 10 9 9 10 9 7 9 10 10 11 10 11 11 12 7 12 9 12 10 12 11 13 8 13 11 5 1 5 3 5 4 5 7 6 1 6 3 7 1 7 2 10 3 11 3 2 1 2 2 3 1 3 2...
result:
ok 6000 lines