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;
struct container {
int l, r;
bool operator < ( container c ) {
return l < c.l;
}
};
const int MAX_N = 1e6;
const int MOD = 1e9 + 7;
int side[MAX_N];
container containers[MAX_N];
int main() {
int n;
cin >> n;
for ( int i = 0; i < n; i++ )
cin >> containers[i].l >> containers[i].r;
sort( containers, containers + n );
int comp = 0;
bool bipartit = true;
for ( int i = 0; i < n; i++ ) {
side[i] = -1;
for ( int j = 0; j < i; j++ ) {
if ( containers[j].r > containers[i].l && containers[j].r < containers[i].r ) {
if ( side[i] == side[j] )
bipartit = false;
else
side[i] = side[j] ^ 1;
}
}
if ( side[i] == -1 ) {
comp++;
side[i] = 0;
}
}
if ( bipartit ) {
int ans = 1;
for ( int i = 0; i < comp; i++ )
ans = ans * 2 % MOD;
cout << ans;
} else
cout << 0;
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... |