QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#244752 | #6305. Chinese Checker | wbjjjjj | WA | 4ms | 3596kb | C++14 | 3.2kb | 2023-11-09 15:21:31 | 2023-11-09 15:21:31 |
Judging History
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: 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
Wrong Answer
time: 4ms
memory: 3596kb
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:
190 371 210 492 377 224 151 39 328 87 1 140 103 65 25 137 391 294 10 214 83 188 263 16 102 236 301 441 172 84 216 281 25 7 104 181 429 282 51 163 266 47 10 152 79 181 30 145 328 122 200 289 0 105 114 54 22 5 59 159 167 26 447 163 209 4 52 0 251 109 100 403 0 348 75 105 75 353 66 28 474 354 6 190 90 ...
result:
wrong answer 2nd numbers differ - expected: '376', found: '371'