제출 #533824

#제출 시각아이디문제언어결과실행 시간메모리
533824Soumya1Port Facility (JOI17_port_facility)C++17
0 / 100
0 ms204 KiB
#include <bits/stdc++.h> #ifdef __LOCAL__ #include <debug_local.h> #endif using namespace std; const int mod = 1e9 + 7; void testCase() { int n; cin >> n; vector<pair<int, int>> a(n); for (auto &[l, r] : a) cin >> l >> r; sort(a.begin(), a.end()); int ans = 1; set<int> s; set<int> c[2]; for (auto [l, r] : a) { auto it = s.lower_bound(l); if (it != s.end() && *it < r && *it > l) { } else { ans += ans; if (ans >= mod) ans -= mod; } s.insert(r); it = c[0].lower_bound(l); bool h = false; if (it != c[0].end() && *it < r && *it > l) { h = true; c[1].insert(r); } it = c[1].lower_bound(l); if (it != c[1].end() && *it < r && *it > l) { c[0].insert(r); if (h) { cout << "0\n"; return; } h = true; } if (!h) { c[0].insert(r); } } cout << ans << "\n"; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); testCase(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...