Submission #577601

#TimeUsernameProblemLanguageResultExecution timeMemory
577601BelguteiRail (IOI14_rail)C++17
30 / 100
71 ms468 KiB
#include "rail.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define ff first #define ss second #define pb push_back #define mk make_pair int n; int d[5005][5005]; int mn = 1e9, mx, x, y; void findLocation(int N, int F, int location[], int stype[]) { //getDistance(0,0); n = N; location[0] = F; stype[0] = 1; // for(int i = 1; i < n; i ++) { d[0][i] = getDistance(0,i); if(mn > d[0][i]) { mn = d[0][i]; x = i; } } location[x] = F + mn; stype[x] = 2; // mx = location[0]; y = 0; for(int i = 0; i < n; i ++) { if(i == 0 || i == x) continue; d[x][i] = getDistance(x,i); if(d[0][x] + d[x][i] == d[0][i]) { location[i] = location[x] - d[x][i]; stype[i] = 1; if(mx < location[i]) { mx = location[i]; y = i; } } } // for(int j = 0; j < n; j ++) { if(j == 0 || j == x || j == y) continue; if( d[0][j] + F == (d[x][j] - (location[x] - location[y]) * 2) + location[x] ) { location[j] = d[0][j] + F; stype[j] = 2; } } mn = 1e9,mx = 0;; int a,b; for(int i = 0; i < n; i ++) { if(stype[i] != 0 && mn > location[i]) { mn = location[i]; a = i; } if(stype[i] != 0 && mx < location[i]) { mx = location[i]; b = i; } } for(int i = 0; i < n; i ++) { if(stype[i] != 0) continue; d[a][i] = getDistance(a,i); int tmp = location[a] + d[a][i]; if(tmp < location[0]) { location[i] = tmp; stype[i] = 2; } } for(int i = 0; i < n; i ++) { if(stype[i] != 0) continue; d[b][i] = getDistance(b,i); int tmp = location[b] - d[b][i]; if(tmp > location[x]) { location[i] = tmp; stype[i] = 1; } } return; }

Compilation message (stderr)

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:76:30: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
   76 |         d[b][i] = getDistance(b,i);
      |                   ~~~~~~~~~~~^~~~~
rail.cpp:67:30: warning: 'a' may be used uninitialized in this function [-Wmaybe-uninitialized]
   67 |         d[a][i] = getDistance(a,i);
      |                   ~~~~~~~~~~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...