2018.09.19 atcoder Snuke's Coloring(思维题)

版权声明:随意转载哦......但还是请注明出处吧: https://blog.csdn.net/dreaming__ldx/article/details/82766277

传送门
谁能想到这道题会写这么久。
本来是一道很sb的题啊。
就是每次选一个点只会影响到周围的九个方格,随便1e9进制就可以hash了,但是我非要作死用stl写。
结果由于技术不够高超,一直调不出来。
然后换成1e9进制的hash发现一直WA。
感觉是long long与int之间卡出了一点问题吧。
然后调了半天终于调过了。
代码:

#include<bits/stdc++.h>
#define N 100007
using namespace std;
int n,h,w,n0,tot=0,a,b;
long long cnt[20],mul=int(1e9)+7,mp[N<<5];
int main(){
	scanf("%d%d%d",&h,&w,&n);
	cnt[0]=1ll*(w-2)*(h-2);
	while(n--){
		scanf("%d%d",&a,&b);
		for(int j=0;j<3;++j)for(int k=0;k<3;++k)
			if(a-j>=1&&a-j<=h-2&&b-k>=1&&b-k<=w-2)mp[tot++]=mul*(a-j)+(b-k);
	}
	sort(mp,mp+tot);
	for(int tmp=1,i=0;i<tot;++i){
		if(mp[i]==mp[i+1])++tmp;
		else ++cnt[tmp],tmp=1,--cnt[0];
	}
	for(int i=0;i<=9;++i)printf("%lld\n",cnt[i]);
	return 0;
}

猜你喜欢

转载自blog.csdn.net/dreaming__ldx/article/details/82766277