Submission #831179

#TimeUsernameProblemLanguageResultExecution timeMemory
831179Darren0724Port Facility (JOI17_port_facility)C++17
0 / 100
1 ms468 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define x first #define y second const int mod=1e9+7; int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n;cin>>n; vector<pair<int,int>> v(n); for(int i=0;i<n;i++){ cin>>v[i].x>>v[i].y; } sort(v.begin(),v.end()); set<int> d; int ans=1; for(int i=0;i<n;i++){ while(d.size()&&*d.begin()<v[i].x){ d.erase(d.begin()); } int cnt=2-d.size(); assert(d.size()<=2); for(int p:d){ if(p>v[i].y){ cnt++; } } ans=ans*cnt%mod; //cout<<v[i].x<<' '<<cnt<<endl; if(ans==0){ cout<<0<<endl; return 0; } d.insert(v[i].y); } cout<<ans<<endl; 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...