제출 #953477

#제출 시각아이디문제언어결과실행 시간메모리
953477Darren0724Port Facility (JOI17_port_facility)C++17
0 / 100
2 ms6492 KiB
#include <bits/stdc++.h> using namespace std; #define LCBorz ios_base::sync_with_stdio(false); cin.tie(0); #define int long long #define all(x) x.begin(), x.end() #define endl '\n' const int N=200005; const int INF=1e18; const int mod=1e9+7; vector<int> adj[N],vis(N); void dfs(int k,int pa){ vis[k]=1; for(int j:adj[k]){ if(j==pa)continue; if(!vis[j]){ dfs(j,k); } else { cout<<0<<endl; exit(0); } } } int32_t main() { LCBorz; int n;cin>>n; vector<int> a(n),b(n); for(int i=0;i<n;i++){ cin>>a[i]>>b[i]; } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(i==j)continue; int cnt=(a[j]>=a[i]&&a[j]<=b[i])+(b[j]>=a[i]&&b[j]<=b[i]); if(cnt==1){ adj[i].push_back(j); } } } int ans=1; for(int i=0;i<n;i++){ if(!vis[i]){ ans=ans*2%mod; dfs(i,i); } } cout<<ans<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...