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;
typedef int64_t llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
//#define endl '\n'
llo n;
llo mod=1e9+7;
pair<llo,llo> it[1000001];
llo vis[1000001];
vector<llo> adj[1000001];
llo st=0;
void dfs(llo no,llo col=1){
vis[no]=col;
for(auto j:adj[no]){
if(vis[j]==0){
dfs(j,3-col);
}
else if(vis[j]==vis[no]){
st=1;
}
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n;
for(llo i=0;i<n;i++){
cin>>it[i].a>>it[i].b;
}
for(llo i=0;i<n;i++){
for(llo j=0;j<n;j++){
if(j==i){
continue;
}
if(it[i].a<=it[j].a and it[i].b<=it[j].b and it[i].b>=it[j].a){
adj[i].pb(j);
adj[j].pb(i);
// cout<<i<<","<<j<<endl;
}
}
}
llo co=0;
for(llo i=0;i<n;i++){
if(vis[i]==0){
dfs(i);
co+=1;
}
}
if(st){
cout<<0<<endl;
}
else{
llo ans=1;
for(llo i=0;i<co;i++){
ans*=2;
ans%=mod;
}
cout<<ans<<endl;
}
return 0;
}
# | 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... |