Submission #212498

#TimeUsernameProblemLanguageResultExecution timeMemory
212498nafis_shifatPort Facility (JOI17_port_facility)C++14
0 / 100
5 ms384 KiB
#include<bits/stdc++.h> #define pii pair<int,int> #define ll long long #define f first #define s second using namespace std; const int inf=1e9; const int mod=1e9+7; int main() { int n; cin>>n; vector<pii> v; int ep[2*n+1]={}; for(int i=0;i<n;i++) { int x,y; cin>>x>>y; v.push_back(make_pair(x,y)); } sort(v.begin(),v.end()); priority_queue<int,vector<int>,greater<int>> pq1,pq2; pq1.push(inf); pq2.push(inf); ll res=1; for(pii i:v) { while(pq1.top()<i.f)pq1.pop(); while(pq2.top()<i.f)pq2.pop(); int t1=pq1.top(); int t2=pq2.top(); if(i.s>t1 && i.s>t2) { cout<<0<<endl; return 0; } if(i.s>t1 && i.s<t2) { pq2.push(i.s); } else if(i.s<t1 && i.s>t2) { pq1.push(i.s); } else { pq1.push(i.s); res*=2; res%=mod; } } cout<<res<<endl; return 0; }

Compilation message (stderr)

port_facility.cpp: In function 'int main()':
port_facility.cpp:16:6: warning: unused variable 'ep' [-Wunused-variable]
  int ep[2*n+1]={};
      ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...