QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#255300#6305. Chinese CheckerSATSKYRE 0ms3620kbC++202.0kb2023-11-18 15:26:092023-11-18 15:26:09

Judging History

你现在查看的是最新测评结果

  • [2023-11-18 15:26:09]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3620kb
  • [2023-11-18 15:26:09]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;using ll=long long;const int M=998244353;
int xn,xm,tc_o,tc_r;
pair<int,int>d[6]={{0,1},{0,-1},{1,0},{-1,0},{1,1},{-1,-1}};
struct chessboard
{
	struct node{bool vld=0;int tim_o=0,tim_r=0;};
	vector<int>l,r;vector<vector<node>>mat;int cnt;
	int getl(int x){if((x>=5&&x<=8)||(x>13))return x-4;return 5;}
	int getr(int x){if((x>=10&&x<=13)||(x<5))return x+4;return 13;}
	chessboard()
	{
		mat.resize(18,vector<node>(18));l.resize(18);r.resize(18);
		for(int i=1;i<=17;i++)l[i]=getl(i),r[i]=getr(i);
		for(int i=1;i<=17;i++)for(int a=l[i],b=r[i],j=a;j<=b;j++)mat[i][j].vld=1;
		//for(int i=1;i<=17;i++)cout<<i<<'/'<<l[i]<<'/'<<r[i]<<'\n';
	}
	void finde(int &y,int &x,int &d,int by,int bx,int dy,int dx)
		{y=by;x=bx;d=0;while(mat[y][x].vld&&mat[y][x].tim_o!=tc_o)y+=dy,x+=dx,d++;}
	void spr(int y,int x)
	{
		//cout<<"spr:"<<bool(mat[y][x].tim_r!=tc_r)<<'$'<<tc_r<<'|'<<y<<'|'<<x<<'\n';
		mat[y][x].tim_r=tc_r,cnt++;
		for(int e=0;e<6;e++)
		{
			int ya,xa,yb,xb,da,db;
			finde(ya,xa,da,y,x,d[e].first,d[e].second);mat[ya][xa].tim_o--;
			finde(yb,xb,db,ya,xa,d[e].first,d[e].second);mat[ya][xa].tim_o++;
			//cout<<e<<"|"<<ya<<'/'<<xa<<"/"<<da<<'|'<<yb<<"/"<<xb<<'/'<<db<<'\n';
			if(db<=da)continue;int ny=ya*2-y,nx=xa*2-x;
			if(mat[ny][nx].tim_r!=tc_r)spr(ny,nx);
		}		
	}
	int solve()
	{
		cnt=0;for(int i=1;i<=17;i++)for(int a=l[i],b=r[i],j=a;j<=b;j++)if(mat[i][j].tim_o==tc_o)
			mat[i][j].tim_o--,mat[i][j].tim_r=++tc_r,cnt--,spr(i,j),mat[i][j].tim_o++;return cnt;
	}
}B;
struct S
{
	int n,m,se;
	void solve()
	{
		cin>>n;tc_o++;for(int i=1,x,y;i<=n;i++)
			cin>>y>>x,x+=B.l[y]-1,B.mat[y][x].tim_o=tc_o;
		cout<<B.solve()<<'\n';
	}
};
void precal()
{
	
}
int main()
{
	//freopen("1.in","r",stdin);
	//cout<<fixed<<setprecision(12);
	ios::sync_with_stdio(0);cin.tie(0);precal();
	int t=1;cin>>t;
	//clock_t a=clock();
	while(t--){S SS;SS.solve();}
	//cout<<"Time:"<<double(clock()-a)<<'\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3620kb

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:


result: