HDU 다중 학교 여섯 번째 1006 원경 - 수학 부문 공간 +

주제 링크 : 포인트 I 아 ╭ (╯ ^ ╰) ╮

효과에 따라 :

    두 가지 차원이있다 점, 만족하고 있습니다
     ( | 엑스 나는 - 엑스 이자형 | + | 나는 - 이자형 | ) (| x_i로부터-x_e | + | y_i-y_e |) 미디엄 모드 케이 나는 = 나는 k_i = t_i
    빌다 ( 엑스 이자형 , 이자형 ) (X_e, y_e)

문제 해결 아이디어 :그림 삽입 설명 여기

    열거 N ^ 2 시 영역
    각각의 영역만을위한 열거 (60) * (60) 60 * 60 크기는 수
    후 합법적 인 영역 내 점의 수를 계산

코어 : 열거 영역, 수학적 사고

#include<bits/stdc++.h>
#define rint register int
#define deb(x) cerr<<#x<<" = "<<(x)<<'\n';
using namespace std;
typedef long long ll;
int T, n, m, tx[15], ty[15];
struct node{
	int x, y, k, t;
} a[15];

bool check(int x, int y){
	for(int i=1; i<=n; i++)
		if((abs(a[i].x-x) + abs(a[i].y-y)) % a[i].k != a[i].t)
			return false;
	return true;
}

ll cal(int l, int r){
	ll cnt = r - l - 1;
	if(cnt < 0) return 0;
	return cnt / 60 + 1;
}

int main() {
	scanf("%d", &T);
	while(T--){
		scanf("%d%d", &n, &m);
		for(int i=1; i<=n; i++){
			scanf("%d%d%d%d", &a[i].x, &a[i].y, &a[i].k, &a[i].t);
			tx[i] = a[i].x, ty[i] = a[i].y;
		}
		tx[n+1] = ty[n+1] = m + 1;
		sort(tx+1, tx+2+n);
		sort(ty+1, ty+2+n);
		int cnt1 = unique(tx+1, tx+2+n) - tx - 1;
		int cnt2 = unique(ty+1, ty+2+n) - ty - 1;
		
		ll ans = 0;
		for(int nx=0; nx<cnt1; nx++)
			for(int ny=0; ny<cnt2; ny++)
				for(int i=0; i<60; i++)
					for(int j=0; j<60; j++)
						if(check(tx[nx]+i, ty[ny]+j))
							ans += cal(tx[nx]+i, tx[nx+1]) * cal(ty[ny]+j, ty[ny+1]);
		printf("%lld\n", ans);
	}
}
게시 된 221 개 원래 기사 · 원 찬양 (220) ·은 20000 +를 볼

추천

출처blog.csdn.net/Scar_Halo/article/details/103037194