제출 #1080848

#제출 시각아이디문제언어결과실행 시간메모리
1080848ALeonidouRoller Coaster Railroad (IOI16_railroad)C++17
0 / 100
191 ms22996 KiB
#include "railroad.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define F first #define S second #define pb push_back #define sz(x) (ll)x.size() typedef vector <ll> vi; typedef pair<ll,ll> ii; typedef vector <ii> vii; #define dbg(x) cout<<#x<<": "<<x<<endl; #define dbg2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl; #define dbg3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<endl; void printVct(vi &v){ for (ll i =0; i<sz(v); i++){ cout<<v[i]<<" "; } cout<<endl; } #define INF 1000000000000000000 #define ins insert ll plan_roller_coaster(vector <int> ss, vector<int> tt) { ll n = sz(ss); vi s(n), t(n); for(ll i =0; i<n; i++){ s[i] = ss[i]; t[i] = tt[i]; } set <ii> set_s; for (ll i =0; i<sz(s); i++){ set_s.ins(ii(s[i], i)); } ll prevIdx = 0, prevBound = t[0]; ll f = -1; while (!set_s.empty()){ set <ii> :: iterator it = set_s.lower_bound(ii(prevBound,0)); if (it == set_s.end()){ f = prevIdx; break; } prevBound = it->F; prevIdx = t[it->S]; set_s.erase(it); } if (set_s.empty()){ return 1; } else{ set_s.clear(); for (ll i =0; i<sz(s); i++){ if (i != f); set_s.ins(ii(s[i], i)); } prevIdx = 0, prevBound = t[0]; while (!set_s.empty()){ set <ii> :: iterator it = set_s.lower_bound(ii(prevBound,0)); if (it == set_s.end()){ break; } prevBound = it->F; prevIdx = t[it->S]; set_s.erase(it); } if (set_s.empty() && s[f] >= prevBound){ return 1; } } return 0; } /* 4 1 1 7 4 3 5 8 6 6 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...