Submission #929841

#TimeUsernameProblemLanguageResultExecution timeMemory
929841PanndaEvent Hopping 2 (JOI21_event2)C++17
1 / 100
74 ms1504 KiB
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 12345; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, k; cin >> n >> k; vector<array<int, 2>> a(n); for (int i = 0; i < n; i++) { int l, r; cin >> l >> r; a[i] = {l, r}; } vector<int> key(k, INF); for (int mask = 0; mask < (1 << n); mask++) { if (__builtin_popcount(mask) != k) continue; vector<int> seq; vector<array<int, 2>> fetch; for (int i = 0; i < n; i++) { if (mask >> i & 1) { seq.push_back(i); fetch.push_back(a[i]); } } sort(fetch.begin(), fetch.end()); bool ok = true; for (int i = 1; i < k; i++) { if (fetch[i][0] < fetch[i - 1][1]) { ok = false; } } if (ok) { key = min(key, seq); } } if (key[0] == INF) { cout << -1 << '\n'; } else { for (int i : key) { cout << i + 1 << '\n'; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...