Submission #1029269

#TimeUsernameProblemLanguageResultExecution timeMemory
1029269berrNetrpeljivost (COI23_netrpeljivost)C++17
100 / 100
402 ms107272 KiB
#include <bits/stdc++.h> using namespace std; #define int long long void f(){ #ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #endif } 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); //f(); 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++) cin >> d[i][l]; } 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++){ if(g&(1<<c)){ int h = g^(1<<c); h&=f; for(int l=0; l<(1<<c); l++){ dp[i][h+l]=min(dp[i][h+l], dp[i-1][g]+d[g][h+l]); } } else{ int h = g^(1<<c); h&=f; for(int l=0; l<(1<<c); l++){ 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; }

Compilation message (stderr)

Main.cpp: In function 'void f()':
Main.cpp:8:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |  freopen("in.txt", "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
Main.cpp:9:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  freopen("out.txt", "w", stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...