This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;
typedef long long ll;
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif
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];
if (a[i] > b[i]) swap(a[i], b[i]);
}
int ans = m;
for (int mask = 0; mask < (1 << m); ++mask) {
vector <int> cnt(n);
for (int i = 0; i < m; ++i) {
if (mask & (1 << i)) {
for (int j = a[i]; j < b[i]; ++j) {
++cnt[j];
}
} else {
for (int j = 0; j < n; ++j) ++cnt[j];
for (int j = a[i]; j < b[i]; ++j) {
--cnt[j];
}
}
}
int mx = 0;
for (int i = 0; i < n; ++i) {
mx = max(mx, cnt[i]);
}
ans = min(ans, mx);
}
cout << ans << '\n';
}
# | 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... |