#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 100005
using namespace std;
struct node{
int x,y;
int p;
int pos;
}x[N],y[N],x_y[N],xy[N],xxy[N],xyy[N],x_yy[N],xx_y[N];
int hited[N];
bool cmpxxy(node a,node b){
if(b.x-a.x==(b.y-a.y)*2)
return a.x<b.x;
return (b.y-a.y)*2<b.x-a.x;
}
bool cmpxyy(node a,node b){
if(b.y-a.y==(b.x-a.x)*2)
return a.x<b.x;
return b.y-a.y<(b.x-a.x)*2;
}
bool cmpxx_y(node a,node b){
if(b.x-a.x==(a.y-b.y)*2)
return a.x<b.x;
return (a.y-b.y)*2<b.x-a.x;
}
bool cmpx_yy(node a,node b){
if(a.y-b.y==(b.x-a.x)*2)
return a.x<b.x;
return a.y-b.y<(b.x-a.x)*2;
}
bool cmpxy(node a,node b){
if(b.x-a.x==b.y-a.y)
return a.x<b.x;
return b.y-a.y<b.x-a.x;
}
bool cmpx_y(node a,node b){
if(b.x-a.x==a.y-b.y)
return a.x<b.x;
return a.y-b.y<b.x-a.x;
}
bool cmpy(node a,node b){
if(a.y==b.y)
return a.x<b.x;
return a.y<b.y;
}
bool cmpx(node a,node b){
if(a.x==b.x)
return a.y<b.y;
return a.x<b.x;
}
int main(){
int t,icase=1;
scanf("%d",&t);
int n;
int xx,yy;
char pp[3];
while(t--){
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d%d%s",&xx,&yy,pp);
x[i].x = y[i].x = x_y[i].x = xy[i].x = xxy[i].x = xyy[i].x = x_yy[i].x = xx_y[i].x = xx;
x[i].y = y[i].y = x_y[i].y = xy[i].y = xxy[i].y = xyy[i].y = x_yy[i].y = xx_y[i].y = yy;
x[i].p = y[i].p = x_y[i].p = xy[i].p = xxy[i].p = xyy[i].p = x_yy[i].p = xx_y[i].p = pp[0]-'A';
x[i].pos = y[i].pos = x_y[i].pos = xy[i].pos = xxy[i].pos = xyy[i].pos = x_yy[i].pos = xx_y[i].pos = i;
}
sort(x,x+n,cmpx);
sort(y,y+n,cmpy);
sort(x_y,x_y+n,cmpx_y);
sort(xy,xy+n,cmpxy);
sort(xxy,xxy+n,cmpxxy);
sort(xyy,xyy+n,cmpxyy);
sort(x_yy,x_yy+n,cmpx_yy);
sort(xx_y,xx_y+n,cmpxx_y);
memset(hited,0,sizeof(hited));
for(int i=0;i<n;i++){
if(x[i].p==10||x[i].p==17||x[i].p==16){
if(i>0){
if(x[i-1].x==x[i].x){
if(x[i].p==10){
if(x[i-1].y+1==x[i].y)
hited[x[i-1].pos]++;
}
else
hited[x[i-1].pos]++;
}
}
if(i<n-1){
if(x[i].x==x[i+1].x){
if(x[i].p==10){
if(x[i].y+1==x[i+1].y)
hited[x[i+1].pos]++;
}
else
hited[x[i+1].pos]++;
}
}
}
if(y[i].p==10||y[i].p==17||y[i].p==16){
if(i>0){
if(y[i-1].y==y[i].y){
if(y[i].p==10){
if(y[i-1].x+1==y[i].x)
hited[y[i-1].pos]++;
}
else
hited[y[i-1].pos]++;
}
}
if(i<n-1){
if(y[i].y==y[i+1].y){
if(y[i].p==10){
if(y[i].x+1==y[i+1].x)
hited[y[i+1].pos]++;
}
else
hited[y[i+1].pos]++;
}
}
}
if(x_y[i].p==10||x_y[i].p==1||x_y[i].p==16){
if(i>0){
if(x_y[i].x-x_y[i-1].x==x_y[i-1].y-x_y[i].y){
if(x_y[i].p==10){
if(x_y[i-1].x+1==x_y[i].x)
hited[x_y[i-1].pos]++;
}
else
hited[x_y[i-1].pos]++;
}
}
if(i<n-1){
if(x_y[i+1].x-x_y[i].x==x_y[i].y-x_y[i+1].y){
if(x_y[i].p==10){
if(x_y[i].x+1==x_y[i+1].x)
hited[x_y[i+1].pos]++;
}
else
hited[x_y[i+1].pos]++;
}
}
}
if(xy[i].p==10||xy[i].p==1||xy[i].p==16){
if(i>0){
if(xy[i].x-xy[i-1].x==xy[i].y-xy[i-1].y){
if(xy[i].p==10){
if(xy[i-1].x+1==xy[i].x)
hited[xy[i-1].pos]++;
}
else
hited[xy[i-1].pos]++;
}
}
if(i<n-1){
if(xy[i+1].x-xy[i].x==xy[i+1].y-xy[i].y){
if(xy[i].p==10){
if(xy[i].x+1==xy[i+1].x)
hited[xy[i+1].pos]++;
}
else
hited[xy[i+1].pos]++;
}
}
}
if(x_yy[i].p==13){
if(i>0){
if((x_yy[i].x-x_yy[i-1].x)*2==x_yy[i-1].y-x_yy[i].y)
if(x_yy[i].x==x_yy[i-1].x+1)
hited[x_yy[i-1].pos]++;
}
if(i<n-1){
if((x_yy[i+1].x-x_yy[i].x)*2==x_yy[i].y-x_yy[i+1].y)
if(x_yy[i+1].x==x_yy[i].x+1)
hited[x_yy[i+1].pos]++;
}
}
if(xx_y[i].p==13){
if(i>0){
if(xx_y[i].x-xx_y[i-1].x==(xx_y[i-1].y-xx_y[i].y)*2)
if(xx_y[i-1].y==xx_y[i].y+1)
hited[xx_y[i-1].pos]++;
}
if(i<n-1){
if(xx_y[i+1].x-xx_y[i].x==(xx_y[i].y-xx_y[i+1].y)*2)
if(xx_y[i].y==xx_y[i+1].y+1)
hited[xx_y[i+1].pos]++;
}
}
if(xxy[i].p==13){
if(i>0){
if(xxy[i].x-xxy[i-1].x==(xxy[i].y-xxy[i-1].y)*2)
if(xxy[i-1].y+1==xxy[i].y)
hited[xxy[i-1].pos]++;
}
if(i<n-1){
if(xxy[i+1].x-xxy[i].x==(xxy[i+1].y-xxy[i].y)*2)
if(xxy[i].y+1==xxy[i+1].y)
hited[xxy[i+1].pos]++;
}
}
if(xyy[i].p==13){
if(i>0){
if((xyy[i].x-xyy[i-1].x)*2==xyy[i].y-xyy[i-1].y)
if(xyy[i-1].x+1==xyy[i].x)
hited[xyy[i-1].pos]++;
}
if(i<n-1){
if((xyy[i+1].x-xyy[i].x)*2==xyy[i+1].y-xyy[i].y)
if(xyy[i].x+1==xyy[i+1].x)
hited[xyy[i+1].pos]++;
}
}
}
int ans[18]={0};
for(int i=0;i<n;i++)
ans[hited[i]]++;
printf("Case %d:\n",icase++);
for(int i=0;i<16;i++)
printf("%d ",ans[i]);
printf("%d\n",ans[16]);
}
return 0;
}
/**************************************
Problem id : SDUT OJ 2415
Result : Accepted
Take Memory : 13372K
Take Time : 420MS
Submit Time : 2014-05-02 00:38:02
**************************************/
sdut2415 Chess (山东第三届省赛)
最新推荐文章于 2019-04-11 19:48:47 发布