//Aleksander Łukasiewicz #include<bits/stdc++.h> using namespace std; #define fru(j,n) for(int j=0; j<(n); ++j) #define tr(it,v) for(typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it) #define x first #define y second #define pb push_back #define mp make_pair #define ALL(G) (G).begin(),(G).end() typedef long long LL; typedef pair<int,int> PII; typedef vector<int> VI; const int INF = 1000000009; const int MAXN = 250*1000; LL Dist(PII A, PII B){ return (LL)(A.x - B.x)*(A.x - B.x) + (LL)(A.y - B.y)*(A.y - B.y); } int mv[] = {0, 1, 1, 0, -1, 0, 0, -1, 1, 1, 1, -1, -1, 1, -1, -1}; int n; PII bears[MAXN + 3], bearscpy[MAXN + 3]; LL Solve(int limak){ for(int i=1; i<=n; i++){ if(i == limak) continue; for(int j=1; j<=n; j++){ if(j == limak) continue; LL curr = Dist(bears[i], bears[j]); if(curr == 0) continue; PII tmp = bears[j]; for(int k=0; k<8; k++){ PII cand = mp(bears[j].x + mv[2*k], bears[j].y + mv[2*k+1]); LL d = Dist(bears[i], cand); if(d < curr){ tmp = cand; curr = d; } } bears[j] = tmp; } } LL ret = 0; for(int i=1; i<=n; i++) ret += (LL)bears[i].x*bears[i].y; for(int i=1; i<=n; i++) bears[i] = bearscpy[i]; return ret; } int main(){ scanf("%d", &n); for(int i=1; i<=n; i++){ scanf("%d %d", &bears[i].x, &bears[i].y); bearscpy[i] = bears[i]; } for(int i=1; i<=n; i++) printf("%lld\n", Solve(i)); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | //Aleksander Łukasiewicz #include<bits/stdc++.h> using namespace std; #define fru(j,n) for(int j=0; j<(n); ++j) #define tr(it,v) for(typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it) #define x first #define y second #define pb push_back #define mp make_pair #define ALL(G) (G).begin(),(G).end() typedef long long LL; typedef pair<int,int> PII; typedef vector<int> VI; const int INF = 1000000009; const int MAXN = 250*1000; LL Dist(PII A, PII B){ return (LL)(A.x - B.x)*(A.x - B.x) + (LL)(A.y - B.y)*(A.y - B.y); } int mv[] = {0, 1, 1, 0, -1, 0, 0, -1, 1, 1, 1, -1, -1, 1, -1, -1}; int n; PII bears[MAXN + 3], bearscpy[MAXN + 3]; LL Solve(int limak){ for(int i=1; i<=n; i++){ if(i == limak) continue; for(int j=1; j<=n; j++){ if(j == limak) continue; LL curr = Dist(bears[i], bears[j]); if(curr == 0) continue; PII tmp = bears[j]; for(int k=0; k<8; k++){ PII cand = mp(bears[j].x + mv[2*k], bears[j].y + mv[2*k+1]); LL d = Dist(bears[i], cand); if(d < curr){ tmp = cand; curr = d; } } bears[j] = tmp; } } LL ret = 0; for(int i=1; i<=n; i++) ret += (LL)bears[i].x*bears[i].y; for(int i=1; i<=n; i++) bears[i] = bearscpy[i]; return ret; } int main(){ scanf("%d", &n); for(int i=1; i<=n; i++){ scanf("%d %d", &bears[i].x, &bears[i].y); bearscpy[i] = bears[i]; } for(int i=1; i<=n; i++) printf("%lld\n", Solve(i)); return 0; } |