# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
18844 |
2016-02-15T23:42:12 Z |
ggoh |
Ideal city (IOI12_city) |
C++ |
|
24 ms |
9444 KB |
#include<cstdio>
#include<map>
#include<queue>
int a,x,y,p,q,i,j,r,u,dx[]={1,0,-1,0},dy[]={0,1,0,-1};
long long sum,mod=1e9;
std::map<int,int>m[100002];
int D[100002];
long long S[100002];
std::queue<int>P,Q;
int DistanceSum (int N, int *X, int *Y)
{
a=N;
x=2147483647;y=2147483647;
for(i=a-1;i>=0;i--)X[i+1]=X[i],Y[i+1]=Y[i];
for(i=1;i<=a;i++)x=std::min(x,X[i]),y=std::min(y,Y[i]);
for(i=1;i<=a;i++)X[i]-=x,Y[i]-=y,m[X[i]][Y[i]]=i;
P.push(X[1]);Q.push(Y[1]);
D[1]=1;S[1]++;
while(!P.empty())
{
p=P.front();P.pop();
q=Q.front();Q.pop();
r=m[p][q];
for(int k=0;k<4;k++)
{
x=p+dx[k];
y=q+dy[k];
if(x>=0&&y>=0&&m[x][y])
{
u=m[x][y];
if(D[u]==0)
{
D[u]=D[r]+1;
S[1]+=D[u];
P.push(x);Q.push(y);
}
}
}
}
S[1]/=(long long)2;
return sum%mod;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
7572 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
7572 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
24 ms |
8652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
24 ms |
9444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |