Submission #31109

# Submission time Handle Problem Language Result Execution time Memory
31109 2017-08-10T01:39:01 Z h0ngjun7 Ideal city (IOI12_city) C++14
11 / 100
1000 ms 40880 KB
#include<bits/stdc++.h>
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int i,j,k;
unordered_map<long long,int>um;
long long dist[2222][2222],ans;
long long f(int x,int y)
{
    return (long long)y+((long long)x<<31);
}
int DistanceSum(int n, int *x, int *y) {
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
            dist[i][j]=4294967296ll;
    for(i=0;i<n;i++)
    {
        um[f(x[i],y[i])]=i+1;
        for(j=0;j<4;j++)
        {
            if(um[f(x[i]+dx[j],y[i]+dy[j])])
            {
                dist[i+1][um[f(x[i]+dx[j],y[i]+dy[j])]]=1;
                dist[um[f(x[i]+dx[j],y[i]+dy[j])]][i+1]=1;
            }
        }
    }
    for(k=1;k<=n;k++)
        for(i=1;i<=n;i++)
            for(j=1;j<=n;j++)
                dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
            if(i!=j)
            {
                //printf("dist[%d][%d]=%d\n",i,j,dist[i][j]);
                ans+=dist[i][j];
            }
    return (ans/2)%1000000000;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 40736 KB Output is correct
2 Correct 0 ms 40736 KB Output is correct
3 Correct 0 ms 40736 KB Output is correct
4 Correct 0 ms 40736 KB Output is correct
5 Correct 0 ms 40736 KB Output is correct
6 Correct 9 ms 40736 KB Output is correct
7 Correct 9 ms 40736 KB Output is correct
8 Correct 9 ms 40736 KB Output is correct
9 Correct 9 ms 40736 KB Output is correct
10 Correct 9 ms 40736 KB Output is correct
11 Correct 13 ms 40736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1000 ms 40868 KB Execution timed out
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 26 ms 40880 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 36 ms 40880 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -