Submission #204002

#TimeUsernameProblemLanguageResultExecution timeMemory
204002CaroLindaWombats (IOI13_wombats)C++14
9 / 100
937 ms20216 KiB
#include "wombats.h" #include <bits/stdc++.h> #define debug printf #define lp(i,a,b) for(int i = a ; i < b ; i++ ) const int inf = 1e9+10 ; const int MAXN = 5005 ; const int MAXM = 205 ; using namespace std ; int N , M ; int resp[MAXM][MAXM] ; int h[MAXN][MAXM] ; int v[MAXN][MAXM] ; //Esta funcao recebe um pedaco do meu grid maior //Com esse pedaco, ela calcula a dp //Stora o resultado na matriz resp[MAXM][MAXM] void calc(int n_menor , int n_maior ) { int dp[MAXN][MAXM] ; for(int curr_c = 0 ; curr_c < M ; curr_c++ ) { //Calculando a distancia de [n_menor][i] para [n_maior][j] , qualquer j lp(i,n_menor, n_maior + 1) lp(j,0,M) dp[i][j] = inf ; dp[n_menor][ curr_c ] = 0 ; for(int i = n_menor ; i <= n_maior ; i++ ) { for(int j = 0 ; j < M ; j++ ) { if( i >= 1 ) dp[i][j] = min( dp[i][j] , dp[i-1][j] + v[i-1][j] ) ; if( j >= 1 ) dp[i][j] = min( dp[i][j] , dp[i][j-1] + h[i][j-1] ) ; } for(int j = M-2 ; j >= 0 ; j-- ) dp[i][j] = min( dp[i][j] , dp[i][j+1] + h[i][j] ) ; } for(int j = 0 ; j < M ; j++ ) resp[ curr_c ][j] = resp[j][ curr_c ] = dp[n_maior][j] ; } } void init(int R, int C, int H[5000][200], int V[5000][200]) { N = R ; M = C ; for(int i = 0 ; i < N ; i++ ) for(int j = 0 ; j < M ; j++ ) { h[i][j] = H[i][j] ; v[i][j] = V[i][j] ; } calc(0,N-1) ; } void changeH(int P, int Q, int W) { h[P][Q] = W ; calc(0,N-1) ; } void changeV(int P, int Q, int W) { v[P][Q] = W ; calc(0,N-1) ; } int escape(int V1, int V2) { return resp[V1][V2] ; }

Compilation message (stderr)

grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
  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...