제출 #129718

#제출 시각아이디문제언어결과실행 시간메모리
129718antimirage철로 (IOI14_rail)C++14
30 / 100
91 ms644 KiB
#include "rail.h" #include <bits/stdc++.h> #define fr first #define sc second #define mk make_pair #define pb push_back #define all(s) s.begin(), s.end() using namespace std; const int N = 5005; int dist[2][N], first; vector <int> lft, op, cl; bool cmp1 (int a, int b) { return dist[0][a] < dist[0][b]; } void findLocation(int n, int pos, int a[], int t[]) { int mn = 1e9 + 7, ind; a[0] = pos, t[0] = 1; for (int i = 1; i < n; i++) { dist[0][i] = getDistance(0, i); if (dist[0][i] < mn) { mn = dist[0][i]; ind = i; } } a[ind] = pos + mn; t[ind] = 2; int L = 0, R = ind; for (int i = 1; i < n; i++) { if (i == ind) continue; lft.pb(i); } sort(all(lft), cmp1); op.pb(L); cl.pb(R); for (auto it : lft) { int res1 = getDistance(L, it); pos = a[L] + res1; if (pos < a[0]) { for (auto i : op) { if (a[i] < a[0] && a[i] < pos && dist[0][it] == dist[0][i] + pos - a[i]) { a[it] = pos; t[it] = 1; op.pb(it); break; } } } if (t[it]) continue; int res2 = getDistance(R, it); pos = a[R] - res2; if (pos > a[0]) { for (auto i : cl) { if (a[i] > a[0] && a[i] > pos && dist[0][it] == dist[0][i] + a[i] - pos) { a[it] = pos; t[it] = 2; cl.pb(it); break; } } } if (t[it]) continue; if (dist[0][it] == dist[0][ind] + a[ind] - pos) { op.pb(it); t[it] = 1; a[it] = pos; L = it; } else { cl.pb(it); t[it] = 2; a[it] = a[L] + res1; R = it; } } }

컴파일 시 표준 에러 (stderr) 메시지

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:33:7: warning: 'ind' may be used uninitialized in this function [-Wmaybe-uninitialized]
  a[ind] = pos + mn; t[ind] = 2;
       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...