Submission #423491

#TimeUsernameProblemLanguageResultExecution timeMemory
423491Theo830Ideal city (IOI12_city)C++17
0 / 100
31 ms1100 KiB
#include <bits/stdc++.h> using namespace std; typedef int ll; const ll INF = 1e9; ll MOD = 998244353; typedef pair<ll,ll> ii; #define iii pair<int,int> #define f(i,a,b) for(ll i = a;i < b;i++) #define pb push_back #define vll vector<ll> #define F first #define S second #define all(x) (x).begin(), (x).end() ///I hope I will get uprating and don't make mistakes ///I will never stop programming ///sqrt(-1) Love C++ ///Please don't hack me ///@TheofanisOrfanou Theo830 ///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst) ///Stay Calm ///Look for special cases ///Beware of overflow and array bounds ///Think the problem backwards ///Training vector<vector<ll> >adj; int DistanceSum(int N, int *X, int *Y){ ll n = N; long long ans = 0; sort(X,X+n); sort(Y,Y+n); ll posa = n-1; ll l = 1; f(i,0,n-1){ ans += (((l * posa) % INF) * (X[i+1] - X[i])) % INF; ans %= INF; ans += (((l * posa) % INF) * (Y[i+1] - Y[i])) % INF; posa--; ans %= INF; l++; } return ans; } /* #define inbuf_len 1 << 16 #define outbuf_len 1 << 16 int DistanceSum(int N, int *X, int *Y); int main() { int tmp; char *inbuf, *outbuf; inbuf = (char*) malloc(inbuf_len * sizeof(char)); outbuf = (char*) malloc(outbuf_len * sizeof(char)); tmp = setvbuf(stdin, inbuf, _IOFBF, inbuf_len); assert(tmp == 0); tmp = setvbuf(stdout, outbuf, _IOFBF, outbuf_len); assert(tmp == 0); int N, i; tmp = scanf("%d", &N); assert(tmp == 1); int *sq_x, *sq_y; sq_x = (int*) malloc(N * sizeof(int)); sq_y = (int*) malloc(N * sizeof(int)); for (i = 0; i < N; i++) { tmp = scanf("%d %d", &sq_x[i], &sq_y[i]); assert(tmp == 2); } int ds = DistanceSum(N, sq_x, sq_y); printf("%d\n", ds); return 0; } */ /* 11 2 5 2 6 3 3 3 6 4 3 4 4 4 5 4 6 5 3 5 4 5 6 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...