Submission #426055

# Submission time Handle Problem Language Result Execution time Memory
426055 2021-06-13T13:21:27 Z oscar1f Race (IOI11_race) C++17
21 / 100
79 ms 8216 KB
#include<bits/stdc++.h>
//#include <cstdio>
//#include <cstdlib>
using namespace std; 


/*#define MAX_N 500000

int N, K;
int H[MAX_N][2];
int L[MAX_N];
int solution;

inline 
void my_assert(int e) {if (!e) abort();}

void read_input()
{
  int i;
  my_assert(2==scanf("%d %d",&N,&K));
  for(i=0; i<N-1; i++)
    my_assert(3==scanf("%d %d %d",&H[i][0],&H[i][1],&L[i]));
  my_assert(1==scanf("%d",&solution));
}*/

const int TAILLE_MAX=1000,INFINI=1000*1000*1000;
int deb;
vector<pair<int,int>> adja[TAILLE_MAX];
int dist[TAILLE_MAX][TAILLE_MAX][2];

void DFS(int pos,int distKm,int distArete) {
  if (dist[deb][pos][0]==-1) {
    dist[deb][pos][0]=distKm;
    dist[deb][pos][1]=distArete;
    for (int ivois=0;ivois<adja[pos].size();ivois++) {
      DFS(adja[pos][ivois].first,distKm+adja[pos][ivois].second,distArete+1);
    }
  }
}

int best_path(int nbSom, int taille, int aretes[][2], int longueurs[]) {
  int record=INFINI;
  for (int i=0;i<nbSom-1;i++) {
    adja[aretes[i][0]].push_back(make_pair(aretes[i][1],longueurs[i]));
    adja[aretes[i][1]].push_back(make_pair(aretes[i][0],longueurs[i]));
  }
  for (int i=0;i<nbSom;i++) {
    for (int j=0;j<nbSom;j++) {
      dist[i][j][0]=-1;
    }
  }
  for (int i=0;i<nbSom;i++) {
    deb=i;
    DFS(i,0,0);
  }
  for (int i=0;i<nbSom;i++) {
    for (int j=0;j<nbSom;j++) {
      if (dist[i][j][0]==taille) {
        record=min(record,dist[i][j][1]);
      }
    }
  }
  if (record==INFINI) {
    record=-1;
  }
  return record;
}
/*
int main()
{
  int ans;
  read_input();
  ans = best_path(N,K,H,L);
  if(ans==solution)
    printf("Correct.\n");
  else
    printf("Incorrect. Returned %d, Expected %d.\n",ans,solution);

  return 0;
}
*/

Compilation message

race.cpp: In function 'void DFS(int, int, int)':
race.cpp:35:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for (int ivois=0;ivois<adja[pos].size();ivois++) {
      |                      ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 716 KB Output is correct
2 Correct 1 ms 716 KB Output is correct
3 Correct 1 ms 716 KB Output is correct
4 Correct 1 ms 716 KB Output is correct
5 Correct 1 ms 716 KB Output is correct
6 Correct 1 ms 716 KB Output is correct
7 Correct 1 ms 716 KB Output is correct
8 Correct 1 ms 716 KB Output is correct
9 Correct 1 ms 716 KB Output is correct
10 Correct 1 ms 716 KB Output is correct
11 Correct 1 ms 716 KB Output is correct
12 Correct 1 ms 716 KB Output is correct
13 Correct 4 ms 716 KB Output is correct
14 Correct 1 ms 716 KB Output is correct
15 Correct 4 ms 708 KB Output is correct
16 Correct 1 ms 708 KB Output is correct
17 Correct 1 ms 716 KB Output is correct
18 Correct 4 ms 716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 716 KB Output is correct
2 Correct 1 ms 716 KB Output is correct
3 Correct 1 ms 716 KB Output is correct
4 Correct 1 ms 716 KB Output is correct
5 Correct 1 ms 716 KB Output is correct
6 Correct 1 ms 716 KB Output is correct
7 Correct 1 ms 716 KB Output is correct
8 Correct 1 ms 716 KB Output is correct
9 Correct 1 ms 716 KB Output is correct
10 Correct 1 ms 716 KB Output is correct
11 Correct 1 ms 716 KB Output is correct
12 Correct 1 ms 716 KB Output is correct
13 Correct 4 ms 716 KB Output is correct
14 Correct 1 ms 716 KB Output is correct
15 Correct 4 ms 708 KB Output is correct
16 Correct 1 ms 708 KB Output is correct
17 Correct 1 ms 716 KB Output is correct
18 Correct 4 ms 716 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 716 KB Output is correct
21 Correct 29 ms 8200 KB Output is correct
22 Correct 29 ms 8144 KB Output is correct
23 Correct 59 ms 8136 KB Output is correct
24 Correct 52 ms 8144 KB Output is correct
25 Correct 79 ms 8132 KB Output is correct
26 Correct 30 ms 8140 KB Output is correct
27 Correct 36 ms 8140 KB Output is correct
28 Correct 32 ms 8156 KB Output is correct
29 Correct 33 ms 8140 KB Output is correct
30 Correct 32 ms 8140 KB Output is correct
31 Correct 33 ms 8096 KB Output is correct
32 Correct 30 ms 8140 KB Output is correct
33 Correct 34 ms 8216 KB Output is correct
34 Correct 22 ms 7600 KB Output is correct
35 Correct 22 ms 7380 KB Output is correct
36 Correct 18 ms 6868 KB Output is correct
37 Correct 18 ms 6988 KB Output is correct
38 Correct 23 ms 7624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 716 KB Output is correct
2 Correct 1 ms 716 KB Output is correct
3 Correct 1 ms 716 KB Output is correct
4 Correct 1 ms 716 KB Output is correct
5 Correct 1 ms 716 KB Output is correct
6 Correct 1 ms 716 KB Output is correct
7 Correct 1 ms 716 KB Output is correct
8 Correct 1 ms 716 KB Output is correct
9 Correct 1 ms 716 KB Output is correct
10 Correct 1 ms 716 KB Output is correct
11 Correct 1 ms 716 KB Output is correct
12 Correct 1 ms 716 KB Output is correct
13 Correct 4 ms 716 KB Output is correct
14 Correct 1 ms 716 KB Output is correct
15 Correct 4 ms 708 KB Output is correct
16 Correct 1 ms 708 KB Output is correct
17 Correct 1 ms 716 KB Output is correct
18 Correct 4 ms 716 KB Output is correct
19 Runtime error 39 ms 4088 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 716 KB Output is correct
2 Correct 1 ms 716 KB Output is correct
3 Correct 1 ms 716 KB Output is correct
4 Correct 1 ms 716 KB Output is correct
5 Correct 1 ms 716 KB Output is correct
6 Correct 1 ms 716 KB Output is correct
7 Correct 1 ms 716 KB Output is correct
8 Correct 1 ms 716 KB Output is correct
9 Correct 1 ms 716 KB Output is correct
10 Correct 1 ms 716 KB Output is correct
11 Correct 1 ms 716 KB Output is correct
12 Correct 1 ms 716 KB Output is correct
13 Correct 4 ms 716 KB Output is correct
14 Correct 1 ms 716 KB Output is correct
15 Correct 4 ms 708 KB Output is correct
16 Correct 1 ms 708 KB Output is correct
17 Correct 1 ms 716 KB Output is correct
18 Correct 4 ms 716 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 716 KB Output is correct
21 Correct 29 ms 8200 KB Output is correct
22 Correct 29 ms 8144 KB Output is correct
23 Correct 59 ms 8136 KB Output is correct
24 Correct 52 ms 8144 KB Output is correct
25 Correct 79 ms 8132 KB Output is correct
26 Correct 30 ms 8140 KB Output is correct
27 Correct 36 ms 8140 KB Output is correct
28 Correct 32 ms 8156 KB Output is correct
29 Correct 33 ms 8140 KB Output is correct
30 Correct 32 ms 8140 KB Output is correct
31 Correct 33 ms 8096 KB Output is correct
32 Correct 30 ms 8140 KB Output is correct
33 Correct 34 ms 8216 KB Output is correct
34 Correct 22 ms 7600 KB Output is correct
35 Correct 22 ms 7380 KB Output is correct
36 Correct 18 ms 6868 KB Output is correct
37 Correct 18 ms 6988 KB Output is correct
38 Correct 23 ms 7624 KB Output is correct
39 Runtime error 39 ms 4088 KB Execution killed with signal 11
40 Halted 0 ms 0 KB -