제출 #1057854

#제출 시각아이디문제언어결과실행 시간메모리
1057854thieunguyenhuy철로 (IOI14_rail)C++17
100 / 100
54 ms97680 KiB
#ifndef hwe #include "rail.h" #endif #include <bits/stdc++.h> using namespace std; #define popcount(n) (__builtin_popcountll((n))) #define clz(n) (__builtin_clzll((n))) #define ctz(n) (__builtin_ctzll((n))) #define lg(n) (63 - __builtin_clzll((n))) #define BIT(n, i) (((n) >> (i)) & 1ll) #define MASK(i) (1ll << (i)) #define FLIP(n, i) ((n) ^ (1ll << (i))) #define ON(n, i) ((n) | MASK(i)) #define OFF(n, i) ((n) & ~MASK(i)) #define Int __int128 #define fi first #define se second typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<int, int> pii; typedef pair<long long, long long> pll; typedef pair<long long, int> pli; typedef pair<int, long long> pil; typedef vector<pair<int, int>> vii; typedef vector<pair<long long, long long>> vll; typedef vector<pair<long long, int>> vli; typedef vector<pair<int, long long>> vil; template <class T1, class T2> bool maximize(T1 &x, T2 y) { if (x < y) { x = y; return true; } return false; } template <class T1, class T2> bool minimize(T1 &x, T2 y) { if (x > y) { x = y; return true; } return false; } template <class T> void remove_duplicate(vector<T> &ve) { sort (ve.begin(), ve.end()); ve.resize(unique(ve.begin(), ve.end()) - ve.begin()); } mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); template <class T> T random(T l, T r) { return uniform_int_distribution<T>(l, r)(rng); } template <class T> T random(T r) { return rng() % r; } const int N = 5000 + 5; const int MOD = 1e9 + 7; const int inf = 1e9; const ll INF = 1e18; int dist[N][N]; #ifdef hwe int getDistance(int i, int j) { return 0; } #endif void findLocation(int n, int first, int location[], int stype[]) { location[0] = first, stype[0] = 1; for (int i = 1; i < n; ++i) dist[0][i] = getDistance(0, i); vector<int> order(n - 1); iota(order.begin(), order.end(), 1); sort (order.begin(), order.end(), [&](int x, int y) { return dist[0][x] < dist[0][y]; }); location[order[0]] = location[0] + dist[0][order[0]], stype[order[0]] = 2; int L = 0, R = order[0]; vector<int> C = {L}, D = {R}; auto check_case12 = [&](int k) { int pos = location[L] + dist[k][L], ma = -inf; if (pos == location[R]) return false; for (auto x : C) { if (location[x] < min(pos, location[R])) maximize(ma, location[x]); } return dist[k][R] == (pos - ma) + (location[R] - ma); }; auto check_case34 = [&](int k) { int pos = location[R] - dist[k][R], mi = inf; if (pos == location[L]) return false; for (auto x : D) { if (location[x] > max(pos, location[L])) minimize(mi, location[x]); } return dist[k][L] == (mi - pos) + (mi - location[L]); }; for (int _ = 1; _ < order.size(); ++_) { int k = order[_]; dist[k][L] = getDistance(k, L), dist[k][R] = getDistance(k, R); if (check_case12(k)) location[k] = location[L] + dist[k][L], stype[k] = 2; else if (check_case34(k)) location[k] = location[R] - dist[k][R], stype[k] = 1; else { if (dist[k][L] == (location[0] - location[L]) + dist[0][k]) location[k] = location[L] + dist[k][L], stype[k] = 2; else location[k] = location[R] - dist[k][R], stype[k] = 1; } if (stype[k] == 1) { C.emplace_back(k); if (location[k] < location[L]) L = k; } else { D.emplace_back(k); if (location[k] > location[R]) R = k; } } } #ifdef hwe signed main() { cerr << '\n'; return 0; } #endif

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

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:109:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  109 |     for (int _ = 1; _ < order.size(); ++_) {
      |                     ~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...