Submission #998928

#TimeUsernameProblemLanguageResultExecution timeMemory
998928amirhoseinfar1385Netrpeljivost (COI23_netrpeljivost)C++17
100 / 100
332 ms125824 KiB
#include<bits/stdc++.h> using namespace std; const long long maxn=2500; long long dp[maxn][maxn],n,cost[maxn][maxn]; long long inf=1e18; void vorod(){ cin>>n; for(long long i=0;i<n;i++){ for(long long j=0;j<n;j++){ cin>>cost[i][j]; } } } void solve(){ for(long long lev=1;lev<n;lev++){ long long pae=(lev&(-lev)); for(long long i=0;i<n;i++){ long long l=(i^pae)&(~(pae-1)); long long r=l+pae; dp[lev][i]=inf; for(long long j=l;j<r;j++){ dp[lev][i]=min(dp[lev][i],dp[lev-1][j]+cost[i][j]); } } } } void khor(){ long long res=inf; for(long long i=0;i<n;i++){ res=min(res,dp[n-1][i]); } cout<<res<<"\n"; } int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); vorod(); solve(); khor(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...