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 <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <deque>
#include <map>
#include <set>
#include <complex>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#define ft first
#define sc second
#define pb push_back
#define len(v) (int)v.size()
#define int ll
using namespace std;
typedef long long ll;
typedef long double ld;
struct cont {
int a, b, i;
bool operator < (const cont& x) const {
return (a < x.a);
}
};
ll mod = 1e9 + 7;
signed main() {
#ifdef PC
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
vector<cont> have(n);
vector<int> color(n, 0);
for (int i = 0; i < n; i++) {
cin >> have[i].a >> have[i].b;
have[i].i = i;
}
sort(have.begin(), have.end());
ll ans = 1;
for (int i = 0; i < n; i++) {
int now = 0;
for (int j = 0; j < n; j++) {
if(!(have[j].a < have[i].a && have[j].b < have[i].b))
continue;
if(have[j].b < have[i].a)
continue;
now |= color[have[j].i];
}
if(now == 3) {
ans = 0;
break;
}
if(now == 0) {
ans = (ans * 2) % mod;
color[have[i].i] = 1;
}
else {
color[have[i].i] = (3 ^ now);
}
}
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... |