Submission #18836

# Submission time Handle Problem Language Result Execution time Memory
18836 2016-02-15T23:10:55 Z ggoh Ideal city (IOI12_city) C++
Compilation error
0 ms 0 KB
#include<cstdio>
#include<map>
#include<queue>
int a,x,y,p,q,i,j,dx[]={1,0,-1,0},dy[]={0,1,0,-1};
long long sum,mod=1e9;
bool m[2002][2002];
std::queue<int>P,Q;
int DistanceSum (int N, int *X, int *Y)
{
    a=N;
    x=2147483647;y=2147483647;
    for(i=0;i<a;i++)x=std::min(x,X[i]),y=std::min(y,Y[i]);
    for(i=0;i<a;i++)X[i]-=x,Y[i]-=y,m[X[i]][Y[i]]=1;
    for(i=0;i<a;i++)
    {
        P.push(X[i]);
        Q.push(Y[i]);
        for(j=0;j<a;j++)D[X[j]][Y[j]]=0;
        D[X[i]][Y[i]]=1;sum++;
        while(!P.empty())
        {
            p=P.front();P.pop();q=Q.front();Q.pop();
            for(int k=0;k<4;k++)
            {
                x=p+dx[k];y=q+dy[k];
                if(x>=0&&y>=0&&m[x][y]&&D[x][y]==0)
                {
                    D[x][y]=D[p][q]+1;
                    sum+=D[x][y];
                    P.push(x);Q.push(y);
                }
            }
        }
        sum-=a;
    }
    sum/=(long long)2;
    return sum%mod;
}

Compilation message

city.cpp: In function ‘int DistanceSum(int, int*, int*)’:
city.cpp:18:25: error: ‘D’ was not declared in this scope
         for(j=0;j<a;j++)D[X[j]][Y[j]]=0;
                         ^
city.cpp:19:9: error: ‘D’ was not declared in this scope
         D[X[i]][Y[i]]=1;sum++;
         ^