Submission #244348

#TimeUsernameProblemLanguageResultExecution timeMemory
244348Osama_AlkhodairyPort Facility (JOI17_port_facility)C++17
22 / 100
6055 ms43896 KiB
#include <bits/stdc++.h> using namespace std; #define finish(x) return cout << x << endl, 0 #define ll long long const int N = 1000001; int n, vis[N], mod = 1e9 + 7; vector <pair <int, int> > a; vector <int> v[N]; void dfs(int node){ for(auto &i : v[node]){ if(vis[i] != -1 && vis[i] != (vis[node] ^ 1)){ cout << 0 << endl; exit(0); } if(vis[i] != -1) continue; vis[i] = vis[node] ^ 1; dfs(i); } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); memset(vis, -1, sizeof vis); cin >> n; a.resize(n); for(auto &i : a) cin >> i.first >> i.second; for(int i = 0 ; i < n ; i++){ for(int j = i + 1 ; j < n ; j++){ pair <int, int> intr = make_pair(max(a[i].first, a[j].first), min(a[i].second, a[j].second)); if(intr.second < intr.first) continue; if(intr == a[i] || intr == a[j]) continue; v[i].push_back(j); v[j].push_back(i); } } int ans = 1; for(int i = 0 ; i < n ; i++){ if(vis[i] != -1) continue; ans *= 2; if(ans >= mod) ans -= mod; vis[i] = 0; dfs(i); } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...