# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
294898 | BThero | Arranging Tickets (JOI17_arranging_tickets) | C++17 | 964 ms | 376 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// chrono::system_clock::now().time_since_epoch().count()
#include<bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " = " << x << endl;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
vector<int> arr[25];
int cnt[25];
int n, m;
void solve() {
scanf("%d %d", &n, &m);
for (int i = 1; i <= m; ++i) {
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
assert(c == 1);
--a;
--b;
while (a != b) {
arr[i].pb(a);
a = (a + 1) % n;
}
}
int ans = m;
for (int mask = 0; mask < (1 << m); ++mask) {
fill(cnt, cnt + n, 0);
for (int i = 1; i <= m; ++i) {
int x = 1;
if ((mask >> i) & 1) {
for (int j = 0; j < n; ++j) {
cnt[j]++;
}
x = -x;
}
for (int y : arr[i]) {
cnt[y] += x;
}
}
ans = min(ans, *max_element(cnt, cnt + n));
}
printf("%d\n", ans);
}
int main() {
int tt = 1;
while (tt--) {
solve();
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |