// Karol Kosinski 2018 #include <cstdio> #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define FOD(i,b,a) for(int i=(b)-1;i>=(a);--i) //#define DEBUG(x...) printf(x) #define DEBUG(x...) using namespace std; typedef unsigned long long LL; const int NX = 250003; int R[NX], C[NX], RA[NX], CA[NX]; int main() { int n; scanf("%d", &n); FOR(i,0,n) scanf("%d%d", R+i, C+i); FOR(limak,0,n) { LL res = 0; FOR(i,0,n) RA[i] = R[i], CA[i] = C[i]; FOR(i,0,n) { if(i == limak) continue; FOR(j,0,n) { if(j == i or j == limak) continue; int r = RA[i] - RA[j]; if(r > 0) ++RA[j]; else if(r < 0) --RA[j]; int c = CA[i] - CA[j]; if(c > 0) ++CA[j]; else if(c < 0) --CA[j]; } } FOR(i,0,n) { DEBUG("(%d, %d) ", RA[i], CA[i]); res += LL(RA[i]) * LL(CA[i]); } DEBUG("\n"); printf("%llu\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 | // Karol Kosinski 2018 #include <cstdio> #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define FOD(i,b,a) for(int i=(b)-1;i>=(a);--i) //#define DEBUG(x...) printf(x) #define DEBUG(x...) using namespace std; typedef unsigned long long LL; const int NX = 250003; int R[NX], C[NX], RA[NX], CA[NX]; int main() { int n; scanf("%d", &n); FOR(i,0,n) scanf("%d%d", R+i, C+i); FOR(limak,0,n) { LL res = 0; FOR(i,0,n) RA[i] = R[i], CA[i] = C[i]; FOR(i,0,n) { if(i == limak) continue; FOR(j,0,n) { if(j == i or j == limak) continue; int r = RA[i] - RA[j]; if(r > 0) ++RA[j]; else if(r < 0) --RA[j]; int c = CA[i] - CA[j]; if(c > 0) ++CA[j]; else if(c < 0) --CA[j]; } } FOR(i,0,n) { DEBUG("(%d, %d) ", RA[i], CA[i]); res += LL(RA[i]) * LL(CA[i]); } DEBUG("\n"); printf("%llu\n", res); } return 0; } |