Submission #1011521

#TimeUsernameProblemLanguageResultExecution timeMemory
1011521MilosMilutinovicArranging Tickets (JOI17_arranging_tickets)C++14
10 / 100
681 ms600 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; vector<int> a(m), b(m), c(m); for (int i = 0; i < m; i++) { cin >> a[i] >> b[i] >> c[i]; --a[i]; --b[i]; } int res = n; for (int mask = 0; mask < (1 << m); mask++) { vector<int> cnt(n); for (int i = 0; i < m; i++) { if (mask >> i & 1) { swap(a[i], b[i]); } int p = a[i]; while (p != b[i]) { cnt[p] += 1; p = (p + 1) % n; } if (mask >> i & 1) { swap(a[i], b[i]); } } res = min(res, *max_element(cnt.begin(), cnt.end())); } cout << res << '\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...
#Verdict Execution timeMemoryGrader output
Fetching results...