# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1062335 | vjudge1 | Port Facility (JOI17_port_facility) | C++17 | 25 ms | 16476 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 <stdio.h>
#include<utility>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
const int N=2005;
int n,a[N],b[N];
vector<int>g[N];
int cut(int i, int j){
return (a[i]<a[j] and b[i] > a[j] and b[i]<b[j])
or(a[j]<a[i] and b[j]>a[i] and b[j]<b[i]);
}
int main() {
scanf("%d",&n);
for(int i=0;i<n;++i)scanf("%d%d",a+i,b+i);
for(int i=0;i<n;++i)for(int j=0;j<n;++j)if(cut(i,j)){
g[i].push_back(j);
}
int comp{};
vector<int>col(n),pw2(1+n);
pw2[0]=1;for(int i=1;i<=n;++i)pw2[i]=pw2[i-1]*2%1000000007;
for(int i=0;i<n;++i){
if(col[i])continue;
queue<int>q;
q.push(i);col[i]=1;
while(q.size()){
auto u=q.front();q.pop();
for(auto v:g[u])
if(0==col[v])col[v]=col[u]==1?2:1,q.push(v);
else if(col[v]==col[u]) return 0*puts("0");
}
++comp;
}
printf("%d\n",pw2[comp]);
}
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... |