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;
using ll = long long;
using ii = pair<int, int>;
#define foru(i, l, r) for(int i=(l); i<=(r); ++i)
#define ford(i, l, r) for(int i=(l); i>=(r); --i)
#define fore(x, v) for(auto &x : v)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define file "input"
void setIO() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
if (fopen(file".inp", "r")) {
freopen(file".inp", "r", stdin);
freopen(file".out", "w", stdout);
}
}
const int MOD = 1e9+7;
const int N = 1e5+5;
int n, evts[N], st[N], en[N];
vector<int> graph[N];
int cnt;
bool vis[N];
int color[N];
void dfs(int u) {
vis[u] = 1;
fore(v, graph[u]) {
if (!vis[v]) { color[v] = color[u]^1; dfs(v); }
else if (color[v] == color[u]) {
cout << 0;
exit(0);
}
}
}
int main() {
setIO();
cin >> n;
foru(i, 1, n) {
cin >> st[i] >> en[i];
evts[st[i]] = i;
evts[en[i]] = i;
}
foru(i, 1, n)
foru(j, 1, n)
if (st[j] < st[i] && st[i] < en[j] && en[j] < en[i]) {
graph[i].push_back(j);
graph[j].push_back(i);
}
foru(i, 1, n) {
if (vis[i]) continue;
dfs(i);
++cnt;
}
int ans = 1;
foru(i, 1, cnt) ans = ans * 2 % MOD;
cout << ans;
}
Compilation message (stderr)
port_facility.cpp: In function 'void setIO()':
port_facility.cpp:19:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
19 | freopen(file".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
port_facility.cpp:20:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
20 | freopen(file".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# | 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... |