제출 #683625

#제출 시각아이디문제언어결과실행 시간메모리
683625NK_Port Facility (JOI17_port_facility)C++17
0 / 100
1 ms212 KiB
// Success consists of going from failure to failure without loss of enthusiasm #include <bits/stdc++.h> using namespace std; #define nl '\n' const int MOD = 1e9+7; int main() { cin.tie(0)->sync_with_stdio(0); int N; cin >> N; int P = N; vector<int> E(2*N); for(int i = 0; i < N; i++) { int a, b; cin >> a >> b; --a, --b; E[a] = b; E[b] = -1; } set<int> S; for(int x = 0; x < 2*N; x++) { if (E[x] == -1) { S.erase(x); } else { int v = E[x]; int amt = 0; for(const auto &c : S) { if (c < v) amt++; else break; if (amt == 2) break; } // cout << v << " " << amt << nl; if (amt == 2) { cout << 0 << nl; return 0; } if (amt == 1) P--; S.insert(v); } } int ans = 1; for(int i = 0; i < P; i++) ans = (2 * ans) % MOD; cout << ans << nl; 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...