# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
27121 | samir_droubi | Port Facility (JOI17_port_facility) | C++14 | 3349 ms | 818728 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>
using namespace std;
int n;
const int mxn=(1e6)+5;
pair<int,int>a[mxn];
int mod=(1e9)+7;
map<int,int>in;
vector<int>gr[mxn];
int vis[mxn];
int ans=1;
queue<int>q;
void bfs()
{
while(!q.empty())
{
int v=q.front();
q.pop();
for(int i=0;i<gr[v].size();++i)
{
int u=gr[v][i];
if(vis[v]==vis[u])
ans=0;
if(vis[u]==-1)
{
vis[u]=1-vis[v];
q.push(u);
}
}
}
}
int main()
{
memset(vis,-1,sizeof vis);
scanf("%d",&n);
for(int i=1;i<=n;++i)
scanf("%d%d",&a[i].first,&a[i].second);
sort(a+1,a+n+1);
for(int i=1;i<=n;++i)
{
map<int,int>::iterator it=in.lower_bound(a[i].first);
for(it;it!=in.end()&&(it->first)<a[i].second;++it)
{
gr[i].push_back(it->second);
gr[it->second].push_back(i);
}
in[a[i].second]=i;
}
for(int i=1;i<=n;++i)
{
if(vis[i]!=-1)continue;
vis[i]=0;
q.push(i);
bfs();
ans*=2;
ans%=mod;
}
printf("%d\n",ans);
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... |