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;
#define ll long long
#define ii pair<ll,ll>
#define fi first
#define se second
#define endl '\n'
#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound
#define rep(x,s,e) for (auto x=s-(s>e);x!=e-(s>e);s<e?x++:x--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MOD=1000000007;
int n;
ii arr[1000005];
vector<int> al[2005];
bool black[2005];
bool vis[2005];
int ans=1;
void dfs(int i){
	vis[i]=true;
	
	for (auto &it:al[i]){
		if (!vis[it]){
			black[it]=!black[i];
			dfs(it);
		}
		else if (black[it]==black[i]){
			ans=0;
		}
	}
}
int main(){
	cin.tie(0);
	cout.tie(0);
	cin.sync_with_stdio(false);
	
	cin>>n;
	
	rep(x,0,n) cin>>arr[x].fi>>arr[x].se;
	rep(x,0,n) rep(y,0,n){
		if (arr[x].fi<arr[y].fi && arr[y].fi<arr[x].se && arr[x].se<arr[y].se){
			al[x].pub(y);
			al[y].pub(x);
			
			//cout<<x<<" "<<y<<endl;
		}
	}
	
	rep(x,0,n) if (!vis[x]){
		dfs(x);
		ans=ans*2%MOD;
	}
	
	cout<<ans<<endl;
}
| # | 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... |