주제 링크 : 포인트 I 아 ╭ (╯ ^ ╰) ╮
효과에 따라 :
두 가지 차원이있다
점, 만족하고 있습니다
빌다
수
문제 해결 아이디어 :
열거
시 영역
각각의 영역만을위한 열거
크기는 수
후 합법적 인 영역 내 점의 수를 계산
코어 : 열거 영역, 수학적 사고
#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);
}
}