# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
798969 | vjudge1 | Port Facility (JOI17_port_facility) | C++17 | 1 ms | 340 KiB |
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;
const int N = 2e3 + 10;
const int MOD = 1e9 + 7;
int n;
vector<int> g[N];
pair<int, int> bounds[N];
int cl[N];
bool flag = 0;
void dfs(int s, int p = -1) {
cl[s] = ((p == -1 || cl[p] == 2) ? 1 : 2);
for(int to : g[s]) {
if(!cl[to]) dfs(to, s);
flag |= (cl[to] == cl[s]);
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin >> n;
for(int i = 0; i < n; i++)
cin >> bounds[i].first >> bounds[i].second;
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
if(bounds[i].first < bounds[j].first & bounds[j].first < bounds[i].second && bounds[i].second < bounds[j].second)
g[i].push_back(j);
if(bounds[i].first > bounds[j].first & bounds[j].first > bounds[i].second && bounds[i].second > bounds[j].second)
g[i].push_back(j);
}
}
int ans = 1;
for(int i = 0; i < n; i++) {
if(cl[i]) continue;
dfs(i);
ans = (ans * 2) % MOD;
}
if(flag) ans = 0;
cout << ans;
}
Compilation message (stderr)
# | 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... |