QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#244751 | #6305. Chinese Checker | wbjjjjj | RE | 0ms | 0kb | C++14 | 3.2kb | 2023-11-09 15:20:41 | 2023-11-09 15:20:45 |
answer
#include<bits/stdc++.h>
using namespace std;
int t,n;
int space[25]={0,4,4,4,4,0,1,2,3,4,3,2,1,0,4,4,4,4};
int num[25]={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 cnt;
int dir[10][5]={{0,1},{1,0},{1,1},{-1,-1},{-1,0},{0,-1}};
int dir2[10][5]={{0,1},{1,-1},{1,0},{-1,0},{-1,1},{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;
return;
}
int _dir(int line,int now_dir,int row)
{
if(line>9) return dir2[now_dir][row];
if(line==9 && now_dir<=2) return dir2[now_dir][row];
return dir[now_dir][row];
}
void dfs(node now,node ori)
{
for(int i=0;i<6;++i)
{
int nxtx=now.first+_dir(now.first,i,0);
int nxty=now.second+_dir(now.first,i,1);
int dis=1;
while(a[nxtx][nxty]==0||(nxtx==ori.first&&nxty==ori.second))
{
nxty+=_dir(nxtx,i,1); nxtx+=_dir(nxtx,i,0);
dis++;
}
if(nxtx==ori.first && nxty==ori.second) continue;
bool judge=0;
if(a[nxtx][nxty]==1)
{
int lastx=nxtx; int lasty=nxty; bool judge=0;
for(int j=1;j<=dis;++j)
{
lasty+=_dir(lastx,i,1);
lastx+=_dir(lastx,i,0);
if(lastx<=17&&lastx>=1&&lasty<=13&&lasty>=1)
if(a[lastx][lasty])
judge=1;
}
if(lastx>17||lastx<1||lasty>13||lasty<1||judge==1) continue;
if((a[lastx][lasty]==0) && vis[lastx][lasty]==0)
{
vis[lastx][lasty]=1;
// cout<<"test "<<now.first<<' '<<now.second-space[now.first]<<' '<<nxtx<<' '<<nxty-space[nxtx]<<' '<<lastx<<' '<<lasty-space[lastx]<<endl;
tot++;
dfs(node(lastx,lasty),ori);
}
}
}
return;
}
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],w[i]);
memset(vis,0,sizeof(vis));
}
cout << tot << endl;
}
system("pause");
return 0;
}
/*
1
8
13 9
13 1
9 4
5 10
11 8
13 4
5 4
9 1
1
23
6 9
3 1
1 1
7 3
8 10
13 9
7 10
11 4
8 4
13 7
5 4
9 7
7 11
8 6
11 2
11 6
10 5
12 10
15 1
13 5
5 1
7 5
6 10
1
2
13 5
10 2
1
12
7 3
8 10
13 2
11 4
7 6
6 6
9 7
6 10
9 4
10 2
11 6
12 5
1
10
13 2
11 4
7 6
6 6
9 7
6 10
9 4
10 2
11 6
12 5
1
9
11 4
7 6
6 6
9 7
6 10
9 4
10 2
11 6
12 5
1
7
11 4
6 6
9 7
9 4
10 2
11 6
12 5
1
6
11 4
6 6
9 7
9 4
11 6
12 5
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Dangerous Syscalls
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