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<bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.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];
}
int ans = m;
for(int i=0; i<(1<<m); ++i) {
vector<int> cnt(n+1);
for(int j=0; j<m; ++j) {
int l = a[j], r = b[j];
if(((1<<j)&i)) {
swap(l, r);
}
while(l != r) {
cnt[l]++;
l++;
if(l==n+1) {
l = 1;
}
}
}
int cur_ans = 0;
for(int j=1; j<=n; ++j) {
cur_ans = max(cur_ans, cnt[j]);
}
ans = min(ans, cur_ans);
}
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... |