Submission #28827

# Submission time Handle Problem Language Result Execution time Memory
28827 2017-07-17T09:18:49 Z Nikefor Race (IOI11_race) C++
0 / 100
3 ms 376 KB
#include "race.h"
int best_path(int N, int K, int H[][2], int L[])
{
    int dis[N][N][2];
    for(int i=0; i<N; i++)
        for(int j=0; j<N; j++) {
            dis[i][j][0] = dis[i][j][1] = (i==j)?0:-1;
        }
    for(int i=0; i<N; i++) {
        int c1 = H[i][0]; int c2 = H[i][1];
        dis[c1][c2][0] = dis[c2][c1][0] = L[i];
        dis[c1][c2][1] = dis[c2][c1][1] = 1;
    }
    for(int i=0; i<N; i++)
        for(int j=0; j<N; j++)
            for(int k=0; k<N; k++) {
                if(dis[i][k][0]==-1 and  dis[i][j][0]!=-1 and dis[j][k][0]!= -1) {
                    dis[i][k][0] = dis[k][i][0] = dis[i][j][0]+dis[j][k][0];
                    dis[i][k][1] = dis[k][i][1] = dis[i][j][1]+dis[j][k][1];
                }
            }
    int opt = -1;
    for(int i=0; i<N; i++)
        for(int j=0; j<N; j++) {
            if(dis[i][j][0] == K and (dis[i][j][1] < opt or opt==-1) ) opt = dis[i][j][1];
        }
  return opt;
}

# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -