제출 #210442

#제출 시각아이디문제언어결과실행 시간메모리
210442dolphingarlicPort Facility (JOI17_port_facility)C++14
100 / 100
1515 ms77560 KiB
#include <bits/stdc++.h> #define FOR(i, x, y) for (int i = x; i < y; i++) typedef long long ll; using namespace std; const ll MOD = 1e9 + 7; pair<int, int> a[1000000]; int cmp[2000000], n; int find(int A) { while (A != cmp[A]) cmp[A] = cmp[cmp[A]], A = cmp[A]; return A; } bool onion(int A, int B) { cmp[find(A)] = find(B); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; FOR(i, 0, n) cin >> a[i].first >> a[i].second; sort(a, a + n); iota(cmp, cmp + 2 * n, 0); set<pair<int, int>> s; FOR(i, 0, n) { while (s.size() && (*s.begin()).first < a[i].first) s.erase(s.begin()); auto ub = s.upper_bound({a[i].second, n}); if (ub != s.begin()) for (ub--;; ub--) { onion(i, (*ub).second + n); onion(i + n, (*ub).second); if (find((*ub).second) == find((*s.begin()).second)) break; if (ub == s.begin()) break; } s.insert({a[i].second, i}); } FOR(i, 0, n) if (find(i) == find(i + n)) return cout << 0, 0; ll cnt = 0, ans = 1; FOR(i, 0, 2 * n) if (find(i) == i) cnt++; FOR(i, 0, cnt / 2) ans = (ans * 2) % MOD; cout << ans; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

port_facility.cpp: In function 'bool onion(int, int)':
port_facility.cpp:16:52: warning: no return statement in function returning non-void [-Wreturn-type]
 bool onion(int A, int B) { cmp[find(A)] = find(B); }
                                                    ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...