Submission #429755

#TimeUsernameProblemLanguageResultExecution timeMemory
429755oscar1fIdeal city (IOI12_city)C++17
23 / 100
40 ms2936 KiB
#include<bits/stdc++.h> /*#include <unordered_map> #include <stdio.h> #include <stdlib.h> #include <assert.h>*/ using namespace std; /*#define inbuf_len 1 << 16 #define outbuf_len 1 << 16*/ const int MOD=1000*1000*1000,MAX_BLOCS=100*1000; int somme,dist,longueur,proch; vector<int> lignes,colonnes; int cumuLig[MAX_BLOCS],cumuCol[MAX_BLOCS]; int calcul(int nb1,int nb2) { long long temp; temp=(long long)nb1*(long long)nb2; temp%=(long long)MOD; return (int) temp; } int DistanceSum(int nbBlocs, int *X, int *Y) { for (int i=0;i<nbBlocs;i++) { lignes.push_back(X[i]); colonnes.push_back(Y[i]); } sort(lignes.begin(),lignes.end()); sort(colonnes.begin(),colonnes.end()); cumuLig[0]=lignes[0]; cumuCol[0]=colonnes[0]; for (int i=1;i<nbBlocs;i++) { cumuLig[i]=lignes[i]+cumuLig[i-1]; cumuLig[i]%=MOD; somme+=calcul(i,lignes[i]); somme%=MOD; somme+=MOD-cumuLig[i-1]; somme%=MOD; cumuCol[i]=colonnes[i]+cumuCol[i-1]; cumuCol[i]%=MOD; somme+=calcul(i,colonnes[i]); somme%=MOD; somme+=MOD-cumuCol[i-1]; somme%=MOD; } return somme; } //int DistanceSum(int N, int *X, int *Y); /* int main() { int tmp; */ /* Set input and output buffering */ /* 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; }*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...