제출 #1190909

#제출 시각아이디문제언어결과실행 시간메모리
1190909keremNetrpeljivost (COI23_netrpeljivost)C++20
100 / 100
380 ms66176 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define int ll #define fr first #define sc second #define pb push_back #define endl "\n" #define all(x) x.begin(),x.end() #define sp << " " << #define inf 1e15 #define N 1000000 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); typedef tuple<int,int,int> tiii; typedef pair<int,int> pii; const int mod=26; int f(int x,int y){ return (x-y+mod)%mod; } void cev(char s,char t,int e,int o,int n){ if(n&1){ if(f(t,s)==f(o,e)) cout << "da" << endl; else cout << "ne" << endl; } else{ if(f(t,s)==f(e,o)) cout << "da" << endl; else cout << "ne" << endl; } } int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); int n; cin >> n; int f[n][n],dp[n][n]; for(int i=0;i<n;i++) for(int j=0;j<n;j++) cin >> f[i][j]; for(int i=0;i<n;i++) dp[i][0]=0; for(int j=1;j<n;j++){ for(int i=0;i<n;i++){ int t=-j&j,l=(i^t)-i%t; dp[i][j]=inf; for(int k=0;k<t;k++) dp[i][j]=min(dp[i][j],dp[l+k][j-1]+f[i][l+k]); } } int ans=inf; for(int i=0;i<n;i++) ans=min(ans,dp[i][n-1]); cout << ans << 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...