#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 time |
Memory |
Grader output |
1 |
Correct |
460 ms |
348 KB |
Output is correct |
2 |
Correct |
453 ms |
432 KB |
Output is correct |
3 |
Correct |
453 ms |
432 KB |
Output is correct |
4 |
Correct |
482 ms |
344 KB |
Output is correct |
5 |
Correct |
449 ms |
348 KB |
Output is correct |
6 |
Correct |
485 ms |
348 KB |
Output is correct |
7 |
Correct |
465 ms |
344 KB |
Output is correct |
8 |
Correct |
484 ms |
428 KB |
Output is correct |
9 |
Correct |
467 ms |
348 KB |
Output is correct |
10 |
Correct |
454 ms |
344 KB |
Output is correct |
11 |
Correct |
476 ms |
432 KB |
Output is correct |
12 |
Correct |
478 ms |
348 KB |
Output is correct |
13 |
Correct |
471 ms |
348 KB |
Output is correct |
14 |
Correct |
478 ms |
600 KB |
Output is correct |
15 |
Correct |
487 ms |
432 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
460 ms |
348 KB |
Output is correct |
2 |
Correct |
453 ms |
432 KB |
Output is correct |
3 |
Correct |
453 ms |
432 KB |
Output is correct |
4 |
Correct |
482 ms |
344 KB |
Output is correct |
5 |
Correct |
449 ms |
348 KB |
Output is correct |
6 |
Correct |
485 ms |
348 KB |
Output is correct |
7 |
Correct |
465 ms |
344 KB |
Output is correct |
8 |
Correct |
484 ms |
428 KB |
Output is correct |
9 |
Correct |
467 ms |
348 KB |
Output is correct |
10 |
Correct |
454 ms |
344 KB |
Output is correct |
11 |
Correct |
476 ms |
432 KB |
Output is correct |
12 |
Correct |
478 ms |
348 KB |
Output is correct |
13 |
Correct |
471 ms |
348 KB |
Output is correct |
14 |
Correct |
478 ms |
600 KB |
Output is correct |
15 |
Correct |
487 ms |
432 KB |
Output is correct |
16 |
Incorrect |
681 ms |
348 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
460 ms |
348 KB |
Output is correct |
2 |
Correct |
453 ms |
432 KB |
Output is correct |
3 |
Correct |
453 ms |
432 KB |
Output is correct |
4 |
Correct |
482 ms |
344 KB |
Output is correct |
5 |
Correct |
449 ms |
348 KB |
Output is correct |
6 |
Correct |
485 ms |
348 KB |
Output is correct |
7 |
Correct |
465 ms |
344 KB |
Output is correct |
8 |
Correct |
484 ms |
428 KB |
Output is correct |
9 |
Correct |
467 ms |
348 KB |
Output is correct |
10 |
Correct |
454 ms |
344 KB |
Output is correct |
11 |
Correct |
476 ms |
432 KB |
Output is correct |
12 |
Correct |
478 ms |
348 KB |
Output is correct |
13 |
Correct |
471 ms |
348 KB |
Output is correct |
14 |
Correct |
478 ms |
600 KB |
Output is correct |
15 |
Correct |
487 ms |
432 KB |
Output is correct |
16 |
Incorrect |
681 ms |
348 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
460 ms |
348 KB |
Output is correct |
2 |
Correct |
453 ms |
432 KB |
Output is correct |
3 |
Correct |
453 ms |
432 KB |
Output is correct |
4 |
Correct |
482 ms |
344 KB |
Output is correct |
5 |
Correct |
449 ms |
348 KB |
Output is correct |
6 |
Correct |
485 ms |
348 KB |
Output is correct |
7 |
Correct |
465 ms |
344 KB |
Output is correct |
8 |
Correct |
484 ms |
428 KB |
Output is correct |
9 |
Correct |
467 ms |
348 KB |
Output is correct |
10 |
Correct |
454 ms |
344 KB |
Output is correct |
11 |
Correct |
476 ms |
432 KB |
Output is correct |
12 |
Correct |
478 ms |
348 KB |
Output is correct |
13 |
Correct |
471 ms |
348 KB |
Output is correct |
14 |
Correct |
478 ms |
600 KB |
Output is correct |
15 |
Correct |
487 ms |
432 KB |
Output is correct |
16 |
Incorrect |
681 ms |
348 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
460 ms |
348 KB |
Output is correct |
2 |
Correct |
453 ms |
432 KB |
Output is correct |
3 |
Correct |
453 ms |
432 KB |
Output is correct |
4 |
Correct |
482 ms |
344 KB |
Output is correct |
5 |
Correct |
449 ms |
348 KB |
Output is correct |
6 |
Correct |
485 ms |
348 KB |
Output is correct |
7 |
Correct |
465 ms |
344 KB |
Output is correct |
8 |
Correct |
484 ms |
428 KB |
Output is correct |
9 |
Correct |
467 ms |
348 KB |
Output is correct |
10 |
Correct |
454 ms |
344 KB |
Output is correct |
11 |
Correct |
476 ms |
432 KB |
Output is correct |
12 |
Correct |
478 ms |
348 KB |
Output is correct |
13 |
Correct |
471 ms |
348 KB |
Output is correct |
14 |
Correct |
478 ms |
600 KB |
Output is correct |
15 |
Correct |
487 ms |
432 KB |
Output is correct |
16 |
Incorrect |
681 ms |
348 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |