제출 #541556

#제출 시각아이디문제언어결과실행 시간메모리
541556dxz05Rail (IOI14_rail)C++14
30 / 100
72 ms972 KiB
#include "rail.h" #include <bits/stdc++.h> using namespace std; void findLocation(int N, int first, int location[], int stype[]){ location[0] = first; stype[0] = 1; vector<int> dist(N); for (int i = 1; i < N; i++) dist[i] = getDistance(0, i); vector<int> perm(N - 1); iota(perm.begin(), perm.end(), 1); sort(perm.begin(), perm.end(), [&](int i, int j){ return dist[i] < dist[j]; }); set<int> C, D; C.insert(first); int P = perm[0]; perm.erase(perm.begin()); location[P] = first + dist[P]; stype[P] = 2; D.insert(location[P]); map<int, int> id = {make_pair(location[0], 0), make_pair(location[P], P)}; int L = 0, R = P; for (int i : perm){ int dL = getDistance(i, L), dR = getDistance(i, R); int p = (location[L] + location[R] + dL - dR) / 2; int x = *--C.upper_bound(p); if (id.find(p) == id.end() && p > x || id.find(p) != id.end() && stype[id[p]] == 1){ location[i] = location[L] + dL; stype[i] = 2; D.insert(location[i]); if (location[i] > location[R]) R = i; } else { location[i] = location[R] - dR; stype[i] = 1; C.insert(location[i]); if (location[i] < location[L]) L = i; } id[location[i]] = i; } }

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

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:39:36: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   39 |         if (id.find(p) == id.end() && p > x || id.find(p) != id.end() && stype[id[p]] == 1){
      |             ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...