이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int l[22], r[22], c[22], l1[22], r1[22];
int qs[22];
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n, m;
cin >> n >> m;
for (int i = 0;i < m;i++) {
cin >> l[i] >> r[i] >> c[i];
if (l[i] > r[i]) {
swap(l[i], r[i]);
}
}
int ans = n;
for (int i = 0;i < (1 << m);i++) {
int mx = 0;
memset(qs, 0, sizeof qs);
for (int j = 0;j < m;j++) {
l1[j] = l[j], r1[j] = r[j];
if (i & (1 << j)) {
swap(l1[j], r1[j]);
}
}
for (int j = 0;j < m;j++) {
if (l1[j] > r1[j]) {
qs[l1[j]]++;
qs[1]++;
qs[r1[j]]--;
}
else {
qs[l1[j]]++;
qs[r1[j]]--;
}
}
for (int i = 1;i <= n;i++) {
qs[i] += qs[i - 1];
mx = max(mx, qs[i]);
}
ans = min(ans, mx);
}
cout << ans << '\n';
return 0;
}
# | 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... |