#include <bits/stdc++.h> using namespace std; #define REP(i,a,b) for (int i = (a); i <= (b); ++i) #define REPD(i,a,b) for (int i = (a); i >= (b); --i) #define FORI(i,n) REP(i,1,n) #define FOR(i,n) REP(i,0,int(n)-1) #define mp make_pair #define pb push_back #define pii pair<int,int> #define vi vector<int> #define ll long long #define SZ(x) int((x).size()) #define DBG(v) cerr << #v << " = " << (v) << endl; #define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++) #define fi first #define se second struct data { int r,c,id; data () { r=c=id=0; } data (int _r, int _c, int _i) { r=_r; c=_c; id=_i; } bool operator< (const data &d) const { if (r!=d.r) return r<d.r; if (c!=d.c) return c<d.c; return id<d.id; } }; const int N = 300300; int n; data t[N], inp[N], s[N]; int main() { scanf("%d", &n); FOR(i,n) { scanf("%d%d", &t[i].r, &t[i].c); t[i].id = i; } FOR(i,n) inp[i] = t[i]; FOR(k,n) { ll res = 0; FOR(i,n) t[i] = inp[i]; FOR(i,n) if (i!=k) { FOR(j,n) if (j!=k) { if (t[j].r < t[i].r) t[j].r++; if (t[j].r > t[i].r) t[j].r--; if (t[j].c < t[i].c) t[j].c++; if (t[j].c > t[i].c) t[j].c--; } } FOR(i,n) res += 1LL * t[i].r * t[i].c; printf("%lld\n", res); } 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 | #include <bits/stdc++.h> using namespace std; #define REP(i,a,b) for (int i = (a); i <= (b); ++i) #define REPD(i,a,b) for (int i = (a); i >= (b); --i) #define FORI(i,n) REP(i,1,n) #define FOR(i,n) REP(i,0,int(n)-1) #define mp make_pair #define pb push_back #define pii pair<int,int> #define vi vector<int> #define ll long long #define SZ(x) int((x).size()) #define DBG(v) cerr << #v << " = " << (v) << endl; #define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++) #define fi first #define se second struct data { int r,c,id; data () { r=c=id=0; } data (int _r, int _c, int _i) { r=_r; c=_c; id=_i; } bool operator< (const data &d) const { if (r!=d.r) return r<d.r; if (c!=d.c) return c<d.c; return id<d.id; } }; const int N = 300300; int n; data t[N], inp[N], s[N]; int main() { scanf("%d", &n); FOR(i,n) { scanf("%d%d", &t[i].r, &t[i].c); t[i].id = i; } FOR(i,n) inp[i] = t[i]; FOR(k,n) { ll res = 0; FOR(i,n) t[i] = inp[i]; FOR(i,n) if (i!=k) { FOR(j,n) if (j!=k) { if (t[j].r < t[i].r) t[j].r++; if (t[j].r > t[i].r) t[j].r--; if (t[j].c < t[i].c) t[j].c++; if (t[j].c > t[i].c) t[j].c--; } } FOR(i,n) res += 1LL * t[i].r * t[i].c; printf("%lld\n", res); } return 0; } |