# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
315193 | juggernaut | Ideal city (IOI12_city) | C++14 | 172 ms | 17280 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<bits/stdc++.h>
//#include"grader.cpp"
using namespace std;
typedef long long ll;
vector<int>g[2005];
int d[2005][2005],res;
int DistanceSum(int n,int *X,int *Y){
if(n<2001){
int i,j;
for(i=0;i+1<n;i++)
for(j=i+1;j<n;j++){d[i][j]=INT_MAX,d[j][i]=INT_MAX;if(abs(X[i]-X[j])+abs(Y[i]-Y[j])==1){
g[i].push_back(j);
g[j].push_back(i);
}}
for(i=0;i<n;i++){
queue<int>q;
q.push(i);
while(!q.empty()){
int v=q.front();
q.pop();
for(int to:g[v])if(d[i][to]>d[i][v]+1){
d[i][to]=d[i][v]+1;
q.push(to);
}
}
}
for(i=0;i+1<n;i++)
for(j=i+1;j<n;j++)res=(res+d[i][j])%(1000000000);
return res;
}
}
/*
11
2 5
2 6
3 3
3 6
4 3
4 4
4 5
4 6
5 3
5 4
5 6
*/
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... |