# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
427119 | jamezzz | Port Facility (JOI17_port_facility) | C++17 | 324 ms | 16436 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;
#define sf scanf
#define pf printf
#define fi first
#define se second
#define pb emplace_back
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
typedef pair<int,int> ii;
typedef long long ll;
#define mod 1000000007
int n,a,b;
int col[2005];
vector<ii> v;
vector<int> AL[2005];
bool dfs(int u){
bool res=true;
for(int v:AL[u]){
if(col[v]==col[u])res=false;
if(col[v]==-1){
col[v]=1-col[u];
res=res&&dfs(v);
}
}
return res;
}
int main(){
sf("%d",&n);
for(int i=0;i<n;++i){
sf("%d%d",&a,&b);
v.pb(a,b);
}
ll ans=1;
sort(all(v));
for(int i=0;i<n;++i){
for(int j=i+1;j<n;++j){
if(v[j].fi<v[i].se&&v[i].se<v[j].se){
AL[i].pb(j);
AL[j].pb(i);
}
}
}
memset(col,-1,sizeof col);
for(int i=0;i<n;++i){
if(col[i]==-1){
col[i]=0;
if(dfs(i))ans*=2,ans%=mod;
else pf("0\n"),exit(0);
}
}
pf("%lld\n",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... |