# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
912824 | Muhammad_Aneeq | Ideal city (IOI12_city) | C++17 | 7 ms | 3164 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
int const MAXN=1e5+10;
vector<int>nei[MAXN]={};
int mod=1e9+10;
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;
}
return ans;
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |