제출 #1062308

#제출 시각아이디문제언어결과실행 시간메모리
106230812345678Port Facility (JOI17_port_facility)C++17
22 / 100
24 ms16732 KiB
#include <bits/stdc++.h> using namespace std; const int nx=2e3+5, mod=1e9+7; int n, l[nx], r[nx], res=1, cnt, c[nx], f, vs[nx]; vector<int> d[nx]; void dfs(int u) { vs[u]=1; for (auto v:d[u]) { if (vs[v]) { if (c[v]==c[u]) f=1; continue; } c[v]=!c[u]; dfs(v); } } int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n; for (int i=1; i<=n; i++) cin>>l[i]>>r[i]; for (int i=1; i<=n; i++) { for (int j=i+1; j<=n; j++) { if ((l[i]<l[j]&&r[j]<r[i])||(l[j]<l[i]&&r[i]<r[j])||r[i]<l[j]||r[j]<l[i]) continue; d[i].push_back(j); d[j].push_back(i); } } for (int i=1; i<=n; i++) if (!vs[i]) dfs(i), res=(res*2)%mod; if (f) cout<<0; else cout<<res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...