제출 #967141

#제출 시각아이디문제언어결과실행 시간메모리
967141ttamxPort Facility (JOI17_port_facility)C++17
0 / 100
0 ms348 KiB
#include<bits/stdc++.h> using namespace std; const int N=2e6+5; const int MOD=1e9+7; int n; int p[N]; int ans=1; stack<pair<int,int>> s; int main(){ cin.tie(nullptr)->sync_with_stdio(false); cin >> n; for(int i=0;i<n;i++){ int l,r; cin >> l >> r; p[l]=r; } s.emplace(2*n+1,0); for(int i=1;i<=2*n;i++)if(p[i]){ while(i>s.top().first)s.pop(); auto &[mx,mx2]=s.top(); if(p[i]>mx){ if(i<mx2)cout << 0,exit(0); else mx2=mx,mx=p[i]; }else{ if(i<mx2&&mx2<p[i])mx2=p[i]; else{ s.emplace(p[i],i); ans*=2; if(ans>=MOD)ans-=MOD; } } } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...