Submission #1026700

#TimeUsernameProblemLanguageResultExecution timeMemory
1026700vjudge1Netrpeljivost (COI23_netrpeljivost)C++17
27 / 100
1561 ms7288 KiB
#include<bits/stdc++.h> using namespace std; #define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define ll long long //#define int long long int #define endl '\n' #define N 600 //#define big 2147483647 #define bigg 9223372036854775807 #define pb push_back //#define p push //#define ins insert #define f first #define s second ll int dp[N][N],arr[N][N]; int nnn; vector<pair<int,int>> hesap(int l,int r){ vector<pair<int,int>> cev; if(l==r){ //dp[l][r]=dp[r][l]=0; cev.pb({l,r}); cev.pb({r,l}); return cev; } int mid=(l+r)/2; vector<pair<int,int>> a=hesap(l,mid), b=hesap(mid+1,r); ll int mn=bigg; for(auto u:a){ int x=u.f, y=u.s; for(auto v:b){ int m=v.f,n=v.s; ll int top=dp[x][y]+dp[m][n]; ll int yes=arr[y][m]; if(dp[x][n]==0){ dp[x][n]=top+yes; cev.pb({x,n}); cev.pb({n,x}); } dp[x][n]=min(dp[x][n],top+yes); dp[n][x]=dp[x][n]; //cout<<x<<" "<<y<<" "<<m<<" "<<n<<": "<<dp[x][n]<<" "<<yes<<" "<<top<<endl; mn=min(mn,dp[x][n]); } } if(l==1&&r==nnn){ cout<<mn<<" "<<endl; } return cev; } signed main(){ lalala; //memset(dp,-1,sizeof(dp)); cin>>nnn; for(int i=1;i<=nnn;i++){ for(int j=1;j<=nnn;j++)cin>>arr[i][j]; } hesap(1,nnn); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...