Submission #139042

#TimeUsernameProblemLanguageResultExecution timeMemory
139042toonewbieRail (IOI14_rail)C++17
30 / 100
542 ms98580 KiB
#include "rail.h"
#include <bits/stdc++.h>

using namespace std;

int dist[5005][5005];
void findLocation(int n, int first, int location[], int stype[]) {
  location[0] = first;
  stype[0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      dist[i][j] = dist[j][i] = getDistance(i, j);
    }
  }
  int mn = 1e9, two;
  for (int i = 1; i < n; ++i) {
    if (dist[i][0] < mn) {
      mn = dist[i][0];
      two = i; 
    }
  }
  location[two] = first + mn;
  stype[two] = 2;
  for (int j = 1; j < n; ++j) {
    if (j == two) continue;
    if (dist[0][j] == dist[two][j]) {
      location[j] = first + dist[0][j];
      stype[j] = 1;
    } else if (dist[0][j] < dist[two][j]) {
      location[j] = first + dist[0][j];
      if (dist[0][j] == dist[j][0]) stype[j] = 2;
      else stype[j] = 1;
    } else if (dist[two][j] < dist[0][j]) {
      location[j] = location[two] - dist[two][j];
      if (dist[two][j] + dist[two][0] == dist[j][0]) stype[j] = 1;
      else stype[j] = 2;
    }
  }
}

Compilation message (stderr)

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:22:15: warning: 'two' may be used uninitialized in this function [-Wmaybe-uninitialized]
   location[two] = first + mn;
               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...