QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#243921 | #6305. Chinese Checker | wbjjjjj | RE | 0ms | 3596kb | C++14 | 1.9kb | 2023-11-08 19:17:15 | 2023-11-08 19:17:16 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int t,n;
int space[20]={0,4,4,4,4,0,1,2,3,4,3,2,1,0,4,4,4,4};
int num[20]={0,1,2,3,4,13,12,11,10,9,10,11,12,13,4,3,2,1};
int a[20][20];
bool vis[20][20];
typedef pair<int,int>node;
vector<node>w;
int tot;
int dir[6][2]={{0,1},{1,0},{1,1},{-1,-1},{-1,0},{0,-1}};
void setbod() // 边界
{
for(int i=1;i<=17;++i)
for(int j=0;j<=space[i];++j)
a[i][j]=-1;
for(int i=1;i<=17;++i)
for(int j=space[i]+num[i]+1;j<=13;++j)
a[i][j]=-1;
for(int i=1;i<=17;++i) a[i][0]=a[i][14]=-1;
for(int i=0;i<=14;++i) a[0][i]=a[18][i]=-1;
}
void dfs(node now,int last_dir,node ori)
{
for(int i=0;i<6;++i)
{
if(i==last_dir) continue;
int nxtx=now.first+dir[i][0];
int nxty=now.second+dir[i][1];
int dis=1;
while(vis[nxtx][nxty]==0 && a[nxtx][nxty]==0)
{
nxtx+=dir[i][0]; nxty+=dir[i][1];
dis++;
}
if(nxtx==ori.first && nxty==ori.second) continue;
if(a[nxtx][nxty]==1)
{
int lastx=nxtx+dis*dir[i][0];
int lasty=nxty+dis*dir[i][1];
if(a[lastx][lasty]==0 && vis[lastx][lasty]==0)
{
vis[lastx][lasty]=1;
tot++;
dfs(node(lastx,lasty),5-i,ori);
}
}
}
}
int main()
{
cin>>t;
while(t--)
{
cin>>n; memset(a,0,sizeof(a));
tot=0;
while(!w.empty()) w.pop_back();
setbod();
for(int i=1;i<=n;++i)
{
int l,r;
cin>>l>>r;
a[l][r+space[l]] = 1;
w.push_back(node(l,r+space[l]));
}
for(int i=0;i<n;++i)
{
dfs(w[i],6,w[i]);
memset(vis,0,sizeof(vis));
}
cout << tot << endl;
}
// system("pause");
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3596kb
input:
5 1 1 1 2 1 1 2 1 2 9 4 9 6 10 1 1 2 1 2 2 3 1 3 2 3 3 4 1 4 2 4 3 4 4 10 1 1 2 1 2 2 5 7 3 2 3 3 4 1 4 2 4 3 4 4
output:
0 1 2 6 13
result:
ok 5 number(s): "0 1 2 6 13"
Test #2:
score: -100
Runtime Error
input:
100 81 1 1 16 1 11 4 13 8 12 3 12 12 11 1 4 2 9 5 8 10 5 5 9 7 3 2 14 1 7 11 13 7 10 2 8 3 9 8 10 6 12 10 6 7 11 2 7 3 13 12 8 6 17 1 10 5 5 12 13 9 13 1 9 4 5 10 11 8 13 4 5 4 9 1 7 8 5 6 13 13 5 1 9 3 8 8 8 5 13 2 13 5 11 3 9 2 6 4 3 3 8 2 13 11 8 7 5 7 6 10 11 9 10 3 11 10 6 3 7 1 4 4 15 2 7 2 3 ...
output:
423 566 284 708 662 305