# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
212498 | nafis_shifat | Port Facility (JOI17_port_facility) | C++14 | 5 ms | 384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |