# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
23672 | rubabredwan | Port Facility (JOI17_port_facility) | C++14 | 103 ms | 19568 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.
/* Bismillahir Rahmanir Rahim */
#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
int n;
int st[N], en[N];
int vis[N], flag, col[N];
vector<int>g[N];
void dfs(int at){
vis[at] = 1;
for(auto u : g[at]){
if(!vis[u]){
col[u] = col[at] ^ 1;
dfs(u);
}
if(col[u] == col[at]) flag = 1;
}
}
int main(){
scanf("%d", &n);
for(int i=1;i<=n;i++) scanf("%d %d", &st[i], &en[i]);
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if(st[j] < st[i] && st[i] < en[j] && en[i] > en[j]){
g[i].push_back(j);
g[j].push_back(i);
}
}
}
int comp = 0;
for(int i=1;i<=n;i++){
if(vis[i]) continue;
col[i] = 0;
dfs(i);
++comp;
}
if(flag) cout << 0 << endl;
else{
long long mod = 1e9 + 7;
long long ret = 1LL;
for(int i=1;i<=comp;i++){
ret *= 2LL;
ret %= mod;
}
cout << ret << endl;
}
return 0;
}
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... |