Submission #990834

#TimeUsernameProblemLanguageResultExecution timeMemory
990834prvocisloPort Facility (JOI17_port_facility)C++17
22 / 100
6028 ms3828 KiB
#include <algorithm> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <string> #include <vector> typedef long long ll; typedef long double ld; using namespace std; const int mod = 1e9 + 7; int mul(int a, int b) { return (a * 1ll * b) % mod; } struct bod { int x, y, i; }; bool over(bod a, bod b) { if (a.x < b.x && b.x < a.y && a.y < b.y) return true; if (b.x < a.x && a.x < b.y && b.y < a.y) return true; return false; } int n, c = 0, ans = 1; vector<bod> a; vector<int> col; void dfs(int u, int c) { col[u] = c; for (int v = 0; v < n; v++) if (over(a[u], a[v])) { if (col[v] == -1) dfs(v, c ^ 1); else if (col[u] == col[v]) ans = 0; } } int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n; a.resize(n), col.resize(n, -1); for (int i = 0; i < n; i++) cin >> a[i].x >> a[i].y, a[i].i = i; for (int i = 0; i < n; i++) if (col[i] == -1) dfs(i, c), c += 2, ans = mul(ans, 2); cout << ans << "\n"; 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...