Submission #912826

#TimeUsernameProblemLanguageResultExecution timeMemory
912826Muhammad_AneeqIdeal city (IOI12_city)C++17
23 / 100
44 ms7792 KiB
#include <cmath> #include <vector> #include <map> #include <algorithm> using namespace std; int const MAXN=1e5+10; vector<int>nei[MAXN]={}; int mod=1e9; int DistanceSum(int N, int X[], int Y[]) { int ans=0; map<int,vector<int>>d; for (int i=0;i<N;i++) d[X[i]].push_back(Y[i]); bool subtask_3=1; for (auto& i:d) { sort(begin(i.second),end(i.second)); if (i.second.size()!=i.second.back()-i.second[0]+1) { subtask_3=0; break; } } if (subtask_3) { sort(Y,Y+N); sort(X,X+N); int ans=0; long long szx=0,sux=0,szy=0,suy=0; for (int i=0;i<N;i++) { long long g=1ll*Y[i]*szy-suy; g%=mod; ans=(ans+g)%mod; g=1ll*X[i]*szx-sux; g%=mod; ans=(ans+g)%mod; szy++; suy+=Y[i]; szx++; sux+=X[i]; } return ans; } return ans; }

Compilation message (stderr)

city.cpp: In function 'int DistanceSum(int, int*, int*)':
city.cpp:19:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} [-Wsign-compare]
   19 |   if (i.second.size()!=i.second.back()-i.second[0]+1)
      |       ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...