Submission #1100977

#TimeUsernameProblemLanguageResultExecution timeMemory
1100977alexander707070Wombats (IOI13_wombats)C++14
12 / 100
16997 ms25680 KiB
#include<bits/stdc++.h> #include "wombats.h" using namespace std; const int inf=1e9; int n,m; int rows[5007][207]; int cols[207][5007]; int dp[207][2][207]; int getsum(int row,int l,int r){ return rows[row][r]-rows[row][l-1]; } void calcdp(){ for(int fin=1;fin<=m;fin++){ for(int r=n;r>=1;r--){ for(int c=1;c<=m;c++){ dp[fin][r%2][c]=inf; if(r==n)dp[fin][r%2][c]=getsum(r,min(c,fin),max(c,fin)-1); else{ for(int k=1;k<=m;k++){ dp[fin][r%2][c]=min(dp[fin][r%2][c],dp[fin][1-r%2][k]+getsum(r,min(k,c),max(k,c)-1)+cols[k][r]); } } } } } } void init(int R, int C, int H[5000][200], int V[5000][200]) { //void init(int R,int C,vector< vector<int> > H,vector< vector<int> > V){ n=R; m=C; for(int i=1;i<=n;i++){ for(int f=1;f<=m-1;f++){ rows[i][f]=H[i-1][f-1]; rows[i][f]+=rows[i][f-1]; } } for(int i=1;i<=m;i++){ for(int f=1;f<=n-1;f++){ cols[i][f]=V[f-1][i-1]; } } calcdp(); } void changeH(int P, int Q, int W) { P++; Q++; int dif=W-(rows[P][Q]-rows[P][Q-1]); for(int i=Q;i<=m-1;i++){ rows[P][i]+=dif; } calcdp(); } void changeV(int P, int Q, int W) { P++; Q++; cols[P][Q]=W; calcdp(); } int escape(int V1, int V2) { V1++; V2++; return dp[V2][1][V1]; } /*int main(){ init(3,4,{{0,2,5},{7,1,1},{0,4,0}},{{0,0,0,2},{0,3,4,7}}); cout<<escape(2,1)<<"\n"; cout<<escape(3,3)<<"\n"; changeV(0,0,5); changeH(1,1,6); cout<<escape(2,1)<<"\n"; return 0; }*/

Compilation message (stderr)

grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
   15 |  int res;
      |      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...