Submission #1021195

# Submission time Handle Problem Language Result Execution time Memory
1021195 2024-07-12T15:34:15 Z amirhoseinfar1385 Wombats (IOI13_wombats) C++17
0 / 100
559 ms 16732 KB
#include "wombats.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn=5000+10,maxm=200+10,t=200,mt=(maxn/t)+5;
int n,m,inf=1e9+5;
struct bakhsh{
    int allr[t+5][maxm],allc[t+5][maxm],dp[maxm][maxm],ps[maxm],suf[maxm];
    void calps(int i){
        for(int j=1;j<=m;j++){
            ps[j]=ps[j-1]+allr[i][j-1];
        }
    }
    void calc(){
        for(int k=1;k<=m;k++){
            calps(0);
            for(int j=1;j<=m;j++){
                dp[k][j]=abs(ps[k]-ps[j]);
            }
            for(int i=1;i<t;i++){
                int mn=inf;
                for(int j=1;j<=m;j++){
                    mn=min(mn+allr[i][j-1],dp[k][j]+allc[i-1][j]);
                    ps[j]=mn;
                }
                mn=inf;
                for(int j=m;j>=1;j--){
                    mn=min(mn+allr[i][j],dp[k][j]+allc[i-1][j]);
                    dp[k][j]=min(ps[j],mn);
                }
            }
            for(int j=1;j<=m;j++){
                dp[k][j]+=allc[t-1][j];
            }
        }
    }
    void updr(int i,int j,int w){
        allr[i][j]=w;
    }
    void updc(int i,int j,int w){
        allc[i][j]=w;
    }
}allsq[mt];

void init( int R, int C, int H[5000][200], int V[5000][200]) {
    n=R;
    m=C;
    for(unsigned int i=0;i<n;i++){
        for(unsigned int j=0;j<m-1;j++){
            allsq[i/t].updr(i%t,j,H[i][j]);
        }
    }
    for(unsigned int i=0;i<n-1;i++){
        for(unsigned int j=0;j<m;j++){
            allsq[i/t].updc(i%t,j,V[i][j]);
        }
    }
    for(int i=0;i<mt;i++){
        allsq[i].calc();
    }
}
 
void changeH( int P, int Q, int W) {
    allsq[P/t].updr(P%t,Q,W);
    allsq[P/t].calc();
}
 
void changeV( int P, int Q, int W) {
    allsq[P/t].updc(P%t,Q,W);
    allsq[P/t].calc();
}
 
int escape( int V1, int V2) {
    return allsq[0].dp[V1][V2];    
}

Compilation message

grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
   15 |  int res;
      |      ^~~
wombats.cpp: In function 'void init(int, int, int (*)[200], int (*)[200])':
wombats.cpp:47:27: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
   47 |     for(unsigned int i=0;i<n;i++){
      |                          ~^~
wombats.cpp:48:31: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
   48 |         for(unsigned int j=0;j<m-1;j++){
      |                              ~^~~~
wombats.cpp:52:27: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
   52 |     for(unsigned int i=0;i<n-1;i++){
      |                          ~^~~~
wombats.cpp:53:31: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
   53 |         for(unsigned int j=0;j<m;j++){
      |                              ~^~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 8796 KB Output is correct
2 Incorrect 5 ms 8644 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Incorrect 0 ms 604 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 559 ms 3328 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 16732 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 540 ms 3400 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 547 ms 3560 KB Output isn't correct
2 Halted 0 ms 0 KB -