#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define pb push_back
#define st first
#define nd second
#define pq priority_queue
#define all(x) begin(x), end(x)
#include <time.h>
#include <cmath>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,ll> pii;
const int i_inf = 1e9;
const ll inf = 1e18;
const ll mod = 1000000007;
const ld eps = 1e-13;
const ld pi = 3.14159265359;
mt19937 _rand(time(NULL));
clock_t timer = clock();
const int mxn = 4e6;
const ll A = 911382323;
const ll B = 972663749;
ll modpow(ll x, ll n){
if(n == 0) return 1%mod;
ll u = modpow(x, n/2);
u = (u * u) % mod;
if(n % 2) u = (u * x) % mod;
return u;
}
ll inverse(ll x){
return modpow(x, mod-2);
}
ll add(ll ans, ll val){
ans = (ans + val) % mod;
return ans;
}
ll mul(ll ans, ll val){
ans = (ans * val) % mod;
return ans;
}
ll sub(ll ans, ll val){
ans = (ans - val) % mod;
if(ans < 0) ans += mod;
return ans;
}
ll _div(ll ans, ll val){
ans = (ans * inverse(val)) % mod;
return ans;
}
ll fakt[mxn];
ll bc(ll n, ll k){
return (fakt[n]*inverse((fakt[k]*fakt[n-k])%mod))%mod;
}
ll sq(ll x){
return x*x;
}
ll rsum(ll a, ll b){
return (b-a+1)*(a+b)/2;
}
void prec(){
fakt[0] = 1;
fr(i, 1, mxn){
fakt[i] = mul(fakt[i-1], i);
}
}
int a[mxn], b[mxn];
vector<int> g[mxn];
int col[mxn];
void dfs(int u){
for(auto e : g[u]){
if(col[e] == -1){
col[e] = col[u]^1;
dfs(e);
}
else if(col[u] == col[e]){
cout<<0<<endl;
exit(0);
}
}
}
void solve(){
int n;
cin >> n;
int val[2*n+1];
memset(val, 0, sizeof(val));
int id[2*n+1];
fr(i, 0, n){
cin >> a[i] >> b[i];
val[a[i]] = +1;
val[b[i]] = -1;
id[a[i]] = id[b[i]] = i;
}
set<int> S;
fr(i, 1, 2*n+1){
if(val[i] == 0) continue;
if(val[i] > 0){
S.insert(-i);
}
else{
int c = id[i];
int l = a[c];
S.erase(-l);
for(auto u : S){
if(-u > l){
g[c].pb(id[-u]);
g[id[-u]].pb(c);
}
else break;
}
}
}
ll ans = 1;
memset(col, -1, sizeof(col));
fr(i, 0, n){
if(col[i] != -1) continue;
col[i] = 0;
dfs(i);
ans = mul(ans, 2);
}
cout<<ans<<endl;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
return 0;
}
Compilation message
/tmp/ccih9G6x.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cciv2cbz.o:bubblesort2.cpp:(.text.startup+0x0): first defined here
/tmp/ccih9G6x.o: In function `main':
grader.cpp:(.text.startup+0x12b): undefined reference to `countScans(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status