Submission #1114339

#TimeUsernameProblemLanguageResultExecution timeMemory
1114339SalihSahinNetrpeljivost (COI23_netrpeljivost)C++14
0 / 100
2 ms6480 KiB
#include <bits/stdc++.h> #define pb push_back #define int long long using namespace std; const int inf = 1e15 + 10; const int N = 3e5 + 5; int dp[1<<11][(1<<11)+1]; int d[(1<<11)+1][(1<<11)+1]; signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for(int i=0; i<=n; i++){ for(int j=0; j<n; j++){ dp[j][i]=1e18; } dp[0][i]=0; } for(int i=0; i<n; i++){ for(int l=0; l<n; l++) d[i][l] = 1; } for(int i=1; i<n; i++){ int c=0, val=i; int f=0; for(int h=0; h<11; h++){ if(val&(1<<h)){ c=h; break; } } for(int h=c; h<=11; h++){ f+=(1<<h); } for(int g=0; g<n; g++){ int h = g^(1<<c); h &= f; for(int l=0; l<(1<<c); l++){ //cout<<g<<" -> "<<h+l<<" i = "<<i<<" deyiz"<<endl; dp[i][h+l]=min(dp[i][h+l], dp[i-1][g] + d[g][h+l]); } } } int mi=1e18; for(int l=0; l<n; l++) mi=min(mi, dp[n-1][l]); cout<<mi<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...