답안 #71373

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
71373 2018-08-24T12:35:39 Z tamtam 웜뱃 (IOI13_wombats) C++14
컴파일 오류
0 ms 0 KB
#include "wombats.h"
#include <bits/stdc++.h>
#define F first
#define S seoncd
typedef long long ll;
using namespace std;

int r,c,sum;
int h[5010][210];
int v[5010][210];
int dp[110][110][3];
int dp1[5010][3][3][5];
int en;

int Solve (int x,int y,int d){
    if (x==r-1&&y==en){
        return 0;
    }
    int &res=dp[x][y][d];
    if (res!=-1)return res;
    res=1000000000;
    if (y>0&&d!=2){
        res=min(res,Solve(x,y-1,1)+h[x][y-1]);
    }
    if (y<c-1&&d!=1){
        res=min(res,Solve(x,y+1,2)+h[x][y]);
    }
    if (x<r-1)
        res=min(res,Solve(x+1,y,0)+v[x][y]);
    return res;
}

int Solve1 (int x,int y,int d,int dpnum){
    if (x==r-1&&y==en){
        return 0;
    }
    int &res=dp1[x][y][d][dpnum];
    if (res!=-1)return res;
    res=1000000000;
    if (y>0&&d!=2){
        res=min(res,Solve1(x,y-1,1)+h[x][y-1]);
    }
    if (y<c-1&&d!=1){
        res=min(res,Solve1(x,y+1,2)+h[x][y]);
    }
    if (x<r-1)
        res=min(res,Solve1(x+1,y,0)+v[x][y]);
    return res;
}

void init(int R, int C, int H[5000][200], int V[5000][200]) {
    r=R;
    c=C;
    for (int i=0;i<r;i++){
        for (int l=0;l<c-1;l++){
            h[i][l]=H[i][l];
        }
    }
    for (int i=0;i<r-1;i++){
        for (int l=0;l<c;l++){
            v[i][l]=V[i][l];
            sum+=v[i][l];
        }
    }
    if (c==2){
    memset(dp1,-1,sizeof dp1);
    en=0;
    Solve1(0,0,0,0);
    Solve1(0,1,0,1);
    en=1;
    Solve1(0,0,0,2);
    Solve1(0,1,0,3);
    }
}

void changeH(int P, int Q, int W) {
    h[P][Q]=W;
    if (c==2){
    memset(dp1,-1,sizeof dp1);
    en=0;
    Solve1(0,0,0,0);
    Solve1(0,1,0,1);
    en=1;
    Solve1(0,0,0,2);
    Solve1(0,1,0,3);
    }
}

void changeV(int P, int Q, int W) {
    sum-=v[P][Q];
    v[P][Q]=W;
    sum+=v[P][Q];
    if (c==2){
    memset(dp1,-1,sizeof dp1);
    en=0;
    Solve1(0,0,0,0);
    Solve1(0,1,0,1);
    en=1;
    Solve1(0,0,0,2);
    Solve1(0,1,0,3);
    }
}

int escape(int V1, int V2) {

    if (c==1){
        return sum;
    }

    if (c==2){
        en=V2;
        return Solve1(0,V1,0,en*2+V1);
    }
    memset(dp,-1,sizeof dp);
    en=V2;
    return Solve(0,V1,0);
}
/*

3 4
0 2 5
7 1 1
0 4 0
0 0 0 2
0 3 4 7
5
3 2 1
3 3 3
2 0 0 5
1 1 1 6
3 2 1

*/

Compilation message

grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
  int res;
      ^~~
wombats.cpp: In function 'int Solve1(int, int, int, int)':
wombats.cpp:41:35: error: too few arguments to function 'int Solve1(int, int, int, int)'
         res=min(res,Solve1(x,y-1,1)+h[x][y-1]);
                                   ^
wombats.cpp:33:5: note: declared here
 int Solve1 (int x,int y,int d,int dpnum){
     ^~~~~~
wombats.cpp:44:35: error: too few arguments to function 'int Solve1(int, int, int, int)'
         res=min(res,Solve1(x,y+1,2)+h[x][y]);
                                   ^
wombats.cpp:33:5: note: declared here
 int Solve1 (int x,int y,int d,int dpnum){
     ^~~~~~
wombats.cpp:47:35: error: too few arguments to function 'int Solve1(int, int, int, int)'
         res=min(res,Solve1(x+1,y,0)+v[x][y]);
                                   ^
wombats.cpp:33:5: note: declared here
 int Solve1 (int x,int y,int d,int dpnum){
     ^~~~~~