Submission #209603

#TimeUsernameProblemLanguageResultExecution timeMemory
209603stefdascaPort Facility (JOI17_port_facility)C++14
0 / 100
5 ms376 KiB
#include<bits/stdc++.h> #define god dimasi5eks #pragma GCC optimize("O3") #define fi first #define se second #define pb push_back #define pf push_front #define mod 1000000007 #define dancila 3.14159265359 #define eps 1e-9 // #define fisier 1 using namespace std; typedef long long ll; int n; pair<int, int> bk[1000002]; bool oki[1000002]; int maxi[2000002]; int main() { #ifdef fisier ifstream f("input.in"); ofstream g("output.out"); #endif ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; for(int i = 1; i <= n; ++i) cin >> bk[i].fi >> bk[i].se; sort(bk + 1, bk + n + 1); int maxx = 0; int poz = 1; for(int i = 1; i <= n+n; ++i) { if(bk[poz].fi == i) maxx = bk[poz].fi, ++poz; maxi[i] = maxx; } maxx = 0; int cnt = 0; int ans = 1; for(int i = 1; i <= n; ++i) { if(maxx > bk[i].se) { oki[i] = 1; if(maxi[bk[i].se] == bk[i].fi) ans = (ans * 2) % mod; } else maxx = bk[i].se, ++cnt; } set<int> x; for(int i = 1; i <= n; ++i) { if(oki[i] == 1) continue; while(!x.empty() && *x.begin() < bk[i].fi) x.erase(x.begin()); if(x.empty() && i != 1) ans = (ans * 2) % mod; x.insert(bk[i].se); if(x.size() >= 3) { cout << 0; return 0; } } ans = (ans * 2) % mod; cout << ans; 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...