제출 #1001889

#제출 시각아이디문제언어결과실행 시간메모리
1001889abczz철로 (IOI14_rail)C++17
0 / 100
42 ms860 KiB
#include "rail.h" #include <iostream> #include <vector> #include <array> #include <algorithm> #define ll long long using namespace std; void findLocation(int N, int first, int location[], int stype[]) { location[0] = first, stype[0] = 1; if (N == 1) return; vector <array<ll, 2>> U, V; ll A[5000], B[5000], mn = 1e18, id, a = first, b, p, tmp; for (int i=1; i<N; ++i) { A[i] = getDistance(0, i); if (mn > A[i]) { mn = A[i], id = i; } } b = location[id] = first + mn; stype[id] = 2; for (int i=0; i<N; ++i) { if (i != id) B[i] = getDistance(id, i); } for (int i=1; i<N; ++i) { if (i == id) continue; if (A[i] < B[i] || abs(A[i]-B[i]) != b-a) { U.push_back({A[i], i}); } else { if (B[i] < mn) { location[i] = b-B[i]; stype[i] = 1; continue; } V.push_back({B[i], i}); } } sort(U.begin(), U.end()); sort(V.begin(), V.end()); p = id; for (int i=0; i<U.size(); ++i) { if (i && U[i][0] != U[i-1][0]) p = tmp; auto [x, y] = U[i]; auto d = getDistance(y, p); if (x+d-mn <= 2*d) { location[y] = a+A[p]-d; stype[y] = 1; } else { location[y] = a+x; stype[y] = 2; tmp = y; } } p = 0; for (int i=0; i<V.size(); ++i) { if (i && V[i][0] != V[i-1][0]) p = tmp; auto [x, y] = V[i]; auto d = getDistance(y, p); if (x+d-mn <= 2*d) { location[y] = b-B[p]+d; stype[y] = 2; } else { location[y] = b-x; stype[y] = 1; tmp = y; } } }

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

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:44:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<long long int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |   for (int i=0; i<U.size(); ++i) {
      |                 ~^~~~~~~~~
rail.cpp:59:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<long long int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |   for (int i=0; i<V.size(); ++i) {
      |                 ~^~~~~~~~~
rail.cpp:22:16: warning: 'id' may be used uninitialized in this function [-Wmaybe-uninitialized]
   22 |   b = location[id] = first + mn;
      |                ^~
rail.cpp:49:26: warning: 'p' may be used uninitialized in this function [-Wmaybe-uninitialized]
   49 |       location[y] = a+A[p]-d;
      |                       ~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...