#include <iostream>
#include <algorithm>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
int *bearX = new int[n];
int *bearY = new int[n];
int *backupX = new int[n];
int *backupY = new int[n];
for(int i=0;i<n;i++)
cin >> backupX[i] >> backupY[i];
for(int lim=0;lim<n;lim++){
copy(backupX, backupX+n, bearX);
copy(backupY, backupY+n, bearY);
for(int i=0;i<n;i++)
if(i!=lim)
for(int j=0;j<n;j++)
if(j!=lim){
// i zaryczał, j się rusza
if(bearX[i] < bearX[j])
bearX[j]--;
else if(bearX[i] > bearX[j])
bearX[j]++;
if(bearY[i] < bearY[j])
bearY[j]--;
else if(bearY[i] > bearY[j])
bearY[j]++;
}
long long res=0;
for(int i=0;i<n;i++)
res += (long long)bearX[i]*bearY[i];
cout << res << "\n";
}
delete []bearX;
delete []bearY;
delete []backupX;
delete []backupY;
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 | #include <iostream> #include <algorithm> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; int *bearX = new int[n]; int *bearY = new int[n]; int *backupX = new int[n]; int *backupY = new int[n]; for(int i=0;i<n;i++) cin >> backupX[i] >> backupY[i]; for(int lim=0;lim<n;lim++){ copy(backupX, backupX+n, bearX); copy(backupY, backupY+n, bearY); for(int i=0;i<n;i++) if(i!=lim) for(int j=0;j<n;j++) if(j!=lim){ // i zaryczał, j się rusza if(bearX[i] < bearX[j]) bearX[j]--; else if(bearX[i] > bearX[j]) bearX[j]++; if(bearY[i] < bearY[j]) bearY[j]--; else if(bearY[i] > bearY[j]) bearY[j]++; } long long res=0; for(int i=0;i<n;i++) res += (long long)bearX[i]*bearY[i]; cout << res << "\n"; } delete []bearX; delete []bearY; delete []backupX; delete []backupY; return 0; } |
English