이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define ep insert
#define endl '\n'
#define elif else if
#define pow pwr
#define sqrt sqrtt
#define int long long
#define ll long long
typedef unsigned long long ull;
using namespace std;
const int N=25;
int a[N],b[N],n,m,f[N];
int rec(int i,int mx){
//cout<<i<<endl;
//for (int j=0;j<n;j++) cout<<f[j]<<' ';cout<<endl<<endl;
if (i>m) return mx;
int x=mx;
for (int j=a[i];j!=b[i];j=(j+1)%n){
f[j]++;
x=max(x,f[j]);
}int ans=rec(i+1,x);
for (int j=a[i];j!=b[i];j=(j+1)%n) f[j]--;
x=mx;
for (int j=b[i];j!=a[i];j=(j+1)%n){
f[j]++;
x=max(x,f[j]);
}ans=min(ans,rec(i+1,x));
for (int j=b[i];j!=a[i];j=(j+1)%n) f[j]--;
return ans;
}
int32_t main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
cin>>n>>m;
for (int i=1;i<=m;i++){
cin>>a[i]>>b[i];
int c;cin>>c;
a[i]--;
b[i]--;
}cout<<rec(1,0)<<endl;
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... |