#include<bits/stdc++.h>
using namespace std;
int bearCount, *x, *y, *xtemp, *ytemp;
void Reset()
{
for (int i = 0; i < bearCount; ++i)
xtemp[i] = x[i], ytemp[i] = y[i];
}
void Roar(int target, int constant)
{
for (int i = 0; i < bearCount; ++i)
{
if (i != target && i != constant)
{
if (ytemp[i] > ytemp[target]) ytemp[i]--;
if (ytemp[i] < ytemp[target]) ytemp[i]++;
if (xtemp[i] > xtemp[target]) xtemp[i]--;
if (xtemp[i] < xtemp[target]) xtemp[i]++;
}
}
}
void Move(int constant)
{
for (int i = 0; i < bearCount; ++i)
if (i != constant)
Roar(i, constant);
}
long long Calculate()
{
long long result = 0;
for (int i = 0; i < bearCount; ++i)
result += xtemp[i] * ytemp[i];
return result;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> bearCount;
x = new int [bearCount];
y = new int [bearCount];
xtemp = new int [bearCount];
ytemp = new int [bearCount];
for (int i = 0; i < bearCount; ++i)
cin >> x[i] >> y[i];
for (int i = 0; i < bearCount; ++i)
{
Reset();
Move(i);
cout << Calculate() << '\n';
}
delete [] x;
delete [] y;
delete [] xtemp;
delete [] ytemp;
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; int bearCount, *x, *y, *xtemp, *ytemp; void Reset() { for (int i = 0; i < bearCount; ++i) xtemp[i] = x[i], ytemp[i] = y[i]; } void Roar(int target, int constant) { for (int i = 0; i < bearCount; ++i) { if (i != target && i != constant) { if (ytemp[i] > ytemp[target]) ytemp[i]--; if (ytemp[i] < ytemp[target]) ytemp[i]++; if (xtemp[i] > xtemp[target]) xtemp[i]--; if (xtemp[i] < xtemp[target]) xtemp[i]++; } } } void Move(int constant) { for (int i = 0; i < bearCount; ++i) if (i != constant) Roar(i, constant); } long long Calculate() { long long result = 0; for (int i = 0; i < bearCount; ++i) result += xtemp[i] * ytemp[i]; return result; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> bearCount; x = new int [bearCount]; y = new int [bearCount]; xtemp = new int [bearCount]; ytemp = new int [bearCount]; for (int i = 0; i < bearCount; ++i) cin >> x[i] >> y[i]; for (int i = 0; i < bearCount; ++i) { Reset(); Move(i); cout << Calculate() << '\n'; } delete [] x; delete [] y; delete [] xtemp; delete [] ytemp; return 0; } |
English