제출 #1118326

#제출 시각아이디문제언어결과실행 시간메모리
1118326crafticatRoller Coaster Railroad (IOI16_railroad)C++17
0 / 100
316 ms41044 KiB
#include <bits/stdc++.h> #ifndef DEBUG #include "railroad.h" #endif using namespace std; template<typename T> using V = vector<T>; using ll = long long; using vi = V<int>; using pi = pair<int,int>; constexpr int INF = 1e9 + 7; #define F0R(i, n) for (int i = 0; i < n;i++) #define FOR(i, j , n) for (int i = j ;i < n;i++) struct Seg { Seg *left = nullptr, *right = nullptr; int l, r, mid; pi v; Seg(int l, int r, vi &arr) : l(l) ,r(r), mid((l + r) / 2) { if (r - l > 1) { left = new Seg(l, mid, arr); right = new Seg(mid, r, arr); v = min(left->v, right->v); } else v = {arr[l], l}; } pi q(int a, int b) { if (b <= l || a >= r) return {INF,INF}; if (a<=l && b>= r) return v; return min(left->q(a,b), right->q(a,b)); } void update(int x, int u) { if (r - l <= 1) { v = {u,l}; return; } if (x < mid) left->update(x,u); else right->update(x,u); v = min(left->v, right->v); } }; #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; Tree<pi> stats; int get(int y) { return stats.order_of_key({y, -1}); } long long plan_roller_coaster(vector<int> a, vector<int> b) { int x = 0; for (auto v : a) { stats.insert({v,x}); x++; } V<pi> dat(a.size()); F0R(i, a.size()) dat[i] = {a[i], b[i]}; std::sort(dat.begin(), dat.end()); vi target(a.size()); F0R(i, a.size()) { target[i] = get(b[i]); } Seg *seg = new Seg(0, a.size(),target); int MAX = 1e9; pi next = seg->q(0, 1e9); int iter = 0; while (next.first != INF) { seg->update(next.second, INF); MAX = next.first; iter++; next = seg->q(MAX, 1e9); } return iter == a.size() ? 0 : 1; } #if DEBUG int main() { int n; assert(1 == scanf("%d", &n)); std::vector<int> s(n), t(n); for (int i = 0; i < n; ++i) assert(2 == scanf("%d%d", &s[i], &t[i])); long long ans = plan_roller_coaster(s, t); printf("%lld\n", ans); return 0; } #endif

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

railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:15:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 | #define F0R(i, n) for (int i = 0; i < n;i++)
......
   70 |     F0R(i, a.size())
      |         ~~~~~~~~~~~                  
railroad.cpp:70:5: note: in expansion of macro 'F0R'
   70 |     F0R(i, a.size())
      |     ^~~
railroad.cpp:15:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 | #define F0R(i, n) for (int i = 0; i < n;i++)
......
   75 |     F0R(i, a.size()) {
      |         ~~~~~~~~~~~                  
railroad.cpp:75:5: note: in expansion of macro 'F0R'
   75 |     F0R(i, a.size()) {
      |     ^~~
railroad.cpp:92:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   92 |     return iter == a.size() ? 0 : 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...