Submission #864329

#TimeUsernameProblemLanguageResultExecution timeMemory
864329NeroZeinPort Facility (JOI17_port_facility)C++17
0 / 100
1 ms348 KiB
#include "bits/stdc++.h" using namespace std; #ifdef Nero #include "Deb.h" #else #define deb(...) #endif const int md = 1e9 + 7; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<pair<int, int>> a(n); for (int i = 0; i < n; ++i) { cin >> a[i].first >> a[i].second; } sort(a.begin(), a.end()); vector<int> o(2 * n + 1); for (int i = 0; i < n; ++i) { o[a[i].second] = i; } int ans = 1; set<int> active; vector<bool> col(n); vector<set<int>> se(2); for (int i = 0; i < n; ++i) { while (!active.empty() && *active.begin() < a[i].first) { int ind = o[*active.begin()]; se[col[ind]].erase(a[ind].second); active.erase(active.begin()); } bool one = se[0].empty() || *se[0].begin() > a[i].second; bool two = se[1].empty() || *se[1].begin() > a[i].second; if (one && two) { col[i] = 0; ans = (ans * 2) % md; se[0].insert(a[i].second); } else if (one) { col[i] = 0; se[0].insert(a[i].second); } else if (two) { col[i] = 1; se[1].insert(a[i].second); } else { ans = 0; break; } active.insert(a[i].second); } cout << ans << '\n'; 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...