이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
cin.sync_with_stdio(0); cin.tie(0);
LL n, m;
cin >> n >> m;
// stations 1 to n
vector<vector<LL> > z;
for(int i = 0; i < m; i++){
LL a, b, c;
cin >> a >> b >> c;
a--; b--;
for(int j = 0; j < c; j++){
z.push_back(vector<LL>({a,b}));
}
}
LL best = z.size();
for(LL r = 0; r < (1 << z.size()); r++){
vector<LL> freq(n,0);
for(int j = 0; j < z.size(); j++){
LL c = z[j][0];
LL d = z[j][1];
if(r & (1 << j)){
swap(c,d);
}
while(c != d){
freq[c]++;
c++;
c %= n;
}
}
LL maxused = 0;
for(int j = 0; j < n; j++){
maxused = max(maxused, freq[j]);
}
best = min(best, maxused);
}
cout << best << '\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... |