제출 #429655

#제출 시각아이디문제언어결과실행 시간메모리
429655Mounir이상적인 도시 (IOI12_city)C++14
0 / 100
7 ms824 KiB
#include <bits/stdc++.h> #define pii pair<int, int> #define x first #define y second #define pb push_back #define all(x) x.begin(), x.end() #define chmin(x, v) x = min(x, v) #define chmax(x, v) x = max(x, v) using namespace std; const int MOD = 1000000000, N = 3000; int delta[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}}; bool estVille[N][N], vue[N][N]; int dist[N][N]; int DistanceSum(int nVilles, int *X, int *Y) { vector<int> x, y; for (int iVille = 0; iVille < nVilles; ++iVille){ x.pb(X[iVille]); y.pb(Y[iVille]); } int SUM = 0; sort(all(x)); sort(all(y)); int sumPg = 0, sumPp = 0; for (int e : x) sumPg += e; sumPg -= x[0]; for (int ind = 0; ind < nVilles; ++ind){ SUM = (SUM + (ind * x[ind] - sumPp + sumPg - (nVilles - 1 - ind) * x[ind]))%MOD; if (ind != nVilles - 1) sumPg -= x[ind + 1]; sumPp += x[ind]; } for (int e :y) sumPg += e; sumPg -= y[0]; for (int ind = 0; ind < nVilles; ++ind){ SUM = (SUM + (ind * y[ind] - sumPp + sumPg - (nVilles - 1 - ind) * y[ind]))%MOD; //cout << "d" << (ind * y[ind] - sumPp + sumPg - (nVilles - 1 - ind) * y[ind]) << endl; if (ind != nVilles - 1) sumPg -= y[ind + 1]; sumPp += y[ind]; } return SUM/2; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...