#include<bits/stdc++.h> using namespace std; #define int long long #define double long double int n; vector<pair<int, int> > v; vector<pair<int, int> > pos; int res; void algo( int id ) { pos = v; for( int i=0; i<n; i++ ) { if( i==id ) continue; for( int j=0; j<n; j++ ) { if( j==id ) continue; if( pos[j].first > pos[i].first ) pos[j].first--; if( pos[j].first < pos[i].first ) pos[j].first++; if( pos[j].second > pos[i].second ) pos[j].second--; if( pos[j].second < pos[i].second ) pos[j].second++; } } res = 0; for( int i=0; i<n; i++ ) { res += pos[i].first*pos[i].second; } cout << res << "\n"; } int32_t main() { ios_base::sync_with_stdio( 0 ); cin.tie( 0 ); cin >> n; for( int a, b, i=1; i<=n; i++ ) { cin >> a >> b; v.push_back( {a, b} ); } for( int i=0; i<n; i++ ) algo( 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 | #include<bits/stdc++.h> using namespace std; #define int long long #define double long double int n; vector<pair<int, int> > v; vector<pair<int, int> > pos; int res; void algo( int id ) { pos = v; for( int i=0; i<n; i++ ) { if( i==id ) continue; for( int j=0; j<n; j++ ) { if( j==id ) continue; if( pos[j].first > pos[i].first ) pos[j].first--; if( pos[j].first < pos[i].first ) pos[j].first++; if( pos[j].second > pos[i].second ) pos[j].second--; if( pos[j].second < pos[i].second ) pos[j].second++; } } res = 0; for( int i=0; i<n; i++ ) { res += pos[i].first*pos[i].second; } cout << res << "\n"; } int32_t main() { ios_base::sync_with_stdio( 0 ); cin.tie( 0 ); cin >> n; for( int a, b, i=1; i<=n; i++ ) { cin >> a >> b; v.push_back( {a, b} ); } for( int i=0; i<n; i++ ) algo( i ); return 0; } |