제출 #792840

#제출 시각아이디문제언어결과실행 시간메모리
792840Ronin13철로 (IOI14_rail)C++17
0 / 100
649 ms98344 KiB
#include "rail.h" #include <bits/stdc++.h> #define ll long long #define ull unsigned ll #define f first #define s second #define pii pair<int,int> #define pll pair<ll,ll> #define pb push_back #define epb emplace_back using namespace std; void findLocation(int N, int first, int location[], int stype[]) { location[0] = first; stype[0] = 1; int n= N; int d[n][n]; for(int i = 0; i < n; i++){ for(int j = i + 1; j < n; j++){ d[i][j] = d[j][i] = getDistance(i, j); } } int mn = 1e9, mni; for(int i = 1; i < n; i++){ if(mn > d[0][i]) mn = d[0][i], mni = i; } //cout << mn << "\n"; int last = mni; while(mni != -1){ int x = mni; last = x; mn = 1e9; mni = -1; for(int i = 0; i < n; i++){ if(i == x) continue; if(mn > d[x][i]) mn = d[x][i], mni = i; } int y = mni; mn = 1e9; mni = -1; for(int i = 0; i < n; i++){ if(d[x][i] != d[x][y] + d[y][i]) continue; if(d[0][i] <= d[0][x]) continue; if(d[x][i] < mn) mn = d[x][i], mni = i; } } location[last] = location[0] + d[0][last]; stype[last] = 2; mn = 1e9; mni = -1; for(int i = 0; i < n; i++){ bool good = true; if(i == last) continue; for(int j = 0; j < n; j++){ if(i == j || i == last) continue; if(d[last][i] == d[last][j] + d[j][i]) { good = false; continue; } } // if(good) cout << i << ' '; if(good) stype[i] = 1, location[i] = location[last] - d[last][i]; if(good && location[i] < mn) mn = location[i], mni = i; } last = mni; // cout << last << ' ' << "\n"; for(int i = 0; i < n; i++){ bool good = true; if(i == last) continue; for(int j = 0; j < n; j++){ if(i == j || i == last) continue; if(d[last][i] == d[last][j] + d[j][i]) { good = false; continue; } } if(good) stype[i] = 2, location[i] = location[last] + d[last][i]; } for(int i = 0; i < n; ++i){ cout << location[i] << ' ' << stype[i] << "\n"; } }

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

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:50:14: warning: 'mni' may be used uninitialized in this function [-Wmaybe-uninitialized]
   50 |     location[last] = location[0] + d[0][last];
      |              ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...