답안 #1100981

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1100981 2024-10-15T07:13:00 Z alexander707070 웜뱃 (IOI13_wombats) C++14
39 / 100
20000 ms 26188 KB
#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[Q][P]=W;

    calcdp();
}

int escape(int V1, int V2) {
    V1++; V2++;

    return dp[V2][1][V1];
}

/*int main(){

    init(4,1,{{}},{{1},{1},{1},{1}});

    cout<<escape(0,0)<<"\n";
    changeV(0,0,2);
    cout<<escape(0,0)<<"\n";
    changeV(1,0,2);
    cout<<escape(0,0)<<"\n";
    changeV(2,0,2);
    cout<<escape(0,0)<<"\n";

    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

grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
   15 |  int res;
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 6736 KB Output is correct
2 Correct 12 ms 6740 KB Output is correct
3 Correct 63 ms 9548 KB Output is correct
4 Correct 11 ms 6904 KB Output is correct
5 Correct 12 ms 6740 KB Output is correct
6 Correct 1 ms 2388 KB Output is correct
7 Correct 1 ms 2388 KB Output is correct
8 Correct 1 ms 2496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 2 ms 6480 KB Output is correct
5 Correct 1 ms 6480 KB Output is correct
6 Correct 2 ms 6480 KB Output is correct
7 Correct 2 ms 6480 KB Output is correct
8 Correct 2 ms 6480 KB Output is correct
9 Correct 2 ms 6480 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 42 ms 7508 KB Output is correct
12 Correct 2 ms 6480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16701 ms 6752 KB Output is correct
2 Correct 16113 ms 6824 KB Output is correct
3 Correct 16812 ms 6840 KB Output is correct
4 Correct 16775 ms 6832 KB Output is correct
5 Correct 16258 ms 6836 KB Output is correct
6 Correct 1 ms 2388 KB Output is correct
7 Correct 1 ms 2388 KB Output is correct
8 Correct 1 ms 2388 KB Output is correct
9 Execution timed out 20084 ms 6740 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 12880 KB Output is correct
2 Correct 58 ms 12940 KB Output is correct
3 Correct 58 ms 12984 KB Output is correct
4 Correct 77 ms 14148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16645 ms 6748 KB Output is correct
2 Correct 16166 ms 6824 KB Output is correct
3 Correct 17253 ms 6836 KB Output is correct
4 Correct 16747 ms 6832 KB Output is correct
5 Correct 16317 ms 6832 KB Output is correct
6 Correct 62 ms 12884 KB Output is correct
7 Correct 57 ms 13048 KB Output is correct
8 Correct 65 ms 12884 KB Output is correct
9 Correct 85 ms 14156 KB Output is correct
10 Correct 12 ms 6740 KB Output is correct
11 Correct 15 ms 6740 KB Output is correct
12 Correct 56 ms 9520 KB Output is correct
13 Correct 12 ms 6740 KB Output is correct
14 Correct 12 ms 6740 KB Output is correct
15 Correct 1 ms 2388 KB Output is correct
16 Correct 1 ms 2388 KB Output is correct
17 Correct 1 ms 2388 KB Output is correct
18 Correct 1 ms 6484 KB Output is correct
19 Correct 2 ms 6484 KB Output is correct
20 Correct 2 ms 6736 KB Output is correct
21 Correct 1 ms 6484 KB Output is correct
22 Correct 2 ms 6484 KB Output is correct
23 Correct 2 ms 6484 KB Output is correct
24 Correct 2 ms 6484 KB Output is correct
25 Correct 40 ms 8868 KB Output is correct
26 Correct 2 ms 6484 KB Output is correct
27 Execution timed out 20089 ms 6824 KB Time limit exceeded
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16583 ms 6756 KB Output is correct
2 Correct 16070 ms 6824 KB Output is correct
3 Correct 16715 ms 6840 KB Output is correct
4 Correct 16727 ms 6836 KB Output is correct
5 Correct 16369 ms 6840 KB Output is correct
6 Correct 63 ms 12884 KB Output is correct
7 Correct 63 ms 12936 KB Output is correct
8 Correct 61 ms 13052 KB Output is correct
9 Correct 80 ms 14200 KB Output is correct
10 Correct 12 ms 6740 KB Output is correct
11 Correct 11 ms 6740 KB Output is correct
12 Correct 51 ms 9548 KB Output is correct
13 Correct 11 ms 6740 KB Output is correct
14 Correct 11 ms 6800 KB Output is correct
15 Execution timed out 20044 ms 26188 KB Time limit exceeded
16 Halted 0 ms 0 KB -