제출 #413282

#제출 시각아이디문제언어결과실행 시간메모리
413282Aryan_RainaPort Facility (JOI17_port_facility)C++17
10 / 100
777 ms504 KiB
#include <bits/stdc++.h> using namespace std; #define int int64_t #define ld long double #define ar array const int INF = 1e12; const int MOD = 1e9+7; void solve() { int N; cin >> N; vector<ar<int,3>> A; for (int i = 0; i < N; i++) { int s, e; cin >> s >> e; A.push_back({s, i, 1}); A.push_back({e, i, 0}); } sort(A.begin(), A.end()); int ans = 0; for (int i = 0; i < (1 << N); i++) { stack<int> remdi[2]; bool omk = true; for (auto [t, j, x] : A) { if (x) remdi[(i >> j) & 1].push(j); else { if (!remdi[0].empty() && remdi[0].top() == j) remdi[0].pop(); else if (!remdi[1].empty() && remdi[1].top() == j) remdi[1].pop(); else omk = false; } } ans += omk; } cout << ans << '\n'; } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; //cin >> t; while (t--) solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...