제출 #1025089

#제출 시각아이디문제언어결과실행 시간메모리
10250890npataRoller Coaster Railroad (IOI16_railroad)C++17
0 / 100
60 ms10560 KiB
#include "railroad.h" #include<bits/stdc++.h> using namespace std; #define vec vector long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { int n = s.size(); vec<pair<int, int>> vs(n); vec<pair<int, int>> vt(n); for(int i = 0; i<n; i++) { vs[i] = {s[i], i}; vt[i] = {t[i], i}; //cerr << s[i] << ' '; } //ncerr << '\n'; sort(vs.begin(), vs.end()); sort(vt.begin(), vt.end()); vec<pair<int, int>> se(0); if(vs[0].second == vt[n-1].second) { se.push_back({vs[0].second, vt[n-2].second}); se.push_back({vs[1].second, vt[n-1].second}); } else { se.push_back({vs[0].second, vt[n-1].second}); } bool ans = false; for(auto [si, ei] : se) { int j = 0; set<int> reach; bool ok = true; for(int i = 0; i<n; i++) { // cerr << "----------------" << i << '\n'; while(j<n && vt[j].first <= vs[i].first) { if(vt[j].second != ei) { reach.insert(ei); } // cerr << vt[j].first << ": " << "shifting" << '\n'; j++; } if(vs[i].second != si) { auto it = reach.begin(); if(it == reach.end()) { ok = false; break; } if(*it == vs[i].second) it++; if(it == reach.end()) { ok = false; break; } reach.erase(it); } // cerr << bal << '\n'; } ans |= ok; } if(ans) return 0; else return 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...