Submission #133897

# Submission time Handle Problem Language Result Execution time Memory
133897 2019-07-21T16:39:03 Z arthurconmy Wombats (IOI13_wombats) C++14
18 / 100
94 ms 17176 KB
#include <bits/stdc++.h>

#ifndef ARTHUR_LOCAL
	#include "wombats.h"
#endif

using namespace std;
using pii=pair<int,int>;

const int INF = 1000000000;
int r=-1;
int c=-1;
int H[5000][200];
int V[5000][200];
int dp[2][5000][2]; // starting from [0][i], ending at [j][k]
int ans[2][2];

void init(int r_raw, int c_raw, int H_raw[5000][200], int V_raw[5000][200])
{
	r=r_raw;
	c=c_raw;

	for(int i=0; i<5000; i++)
	{
		for(int j=0; j<200; j++)
		{
			H[i][j]=H_raw[i][j];
			V[i][j]=V_raw[i][j];
		}
	}

	dp[0][0][0]=0;
	dp[0][0][1]=H[0][0];
	dp[1][0][0]=H[0][0];
	dp[1][0][1]=0;

	for(int i=1; i<r; i++)
	{
		dp[0][i][0] = min(dp[0][i-1][0]+V[i-1][0], dp[0][i-1][1]+V[i-1][1]+H[i][0]);
		dp[0][i][1] = min(dp[0][i-1][1]+V[i-1][1], dp[0][i-1][0]+V[i-1][0]+H[i][0]);
	
		dp[1][i][0] = min(dp[1][i-1][0]+V[i-1][0], dp[1][i-1][1]+V[i-1][1]+H[i][0]);
		dp[1][i][1] = min(dp[1][i-1][1]+V[i-1][1], dp[1][i-1][0]+V[i-1][0]+H[i][0]);

		// cout << dp[0][i][0] << " " << dp[0][i][1] << endl;
	}
}

void changeH(int p, int q, int w)
{
	H[p][q]=w;

	dp[0][0][0]=0;
	dp[0][0][1]=H[0][0];
	dp[1][0][0]=H[0][0];
	dp[1][0][1]=0;

	for(int i=1; i<r; i++)
	{
		dp[0][i][0] = min(dp[0][i-1][0]+V[i-1][0], dp[0][i-1][1]+V[i-1][1]+H[i][0]);
		dp[0][i][1] = min(dp[0][i-1][1]+V[i-1][1], dp[0][i-1][0]+V[i-1][0]+H[i][0]);
	
		dp[1][i][0] = min(dp[1][i-1][0]+V[i-1][0], dp[1][i-1][1]+V[i-1][1]+H[i][0]);
		dp[1][i][1] = min(dp[1][i-1][1]+V[i-1][1], dp[1][i-1][0]+V[i-1][0]+H[i][0]);
	}
}

void changeV(int p, int q, int w)
{
	V[p][q]=w;

	dp[0][0][0]=0;
	dp[0][0][1]=H[0][0];
	dp[1][0][0]=H[0][0];
	dp[1][0][1]=0;

	for(int i=1; i<r; i++)
	{
		dp[0][i][0] = min(dp[0][i-1][0]+V[i-1][0], dp[0][i-1][1]+V[i-1][1]+H[i][0]);
		dp[0][i][1] = min(dp[0][i-1][1]+V[i-1][1], dp[0][i-1][0]+V[i-1][0]+H[i][0]);
	
		dp[1][i][0] = min(dp[1][i-1][0]+V[i-1][0], dp[1][i-1][1]+V[i-1][1]+H[i][0]);
		dp[1][i][1] = min(dp[1][i-1][1]+V[i-1][1], dp[1][i-1][0]+V[i-1][0]+H[i][0]);
	}
}


int escape(int v1, int v2)
{
	#ifdef ARTHUR_LOCAL
		cout << dp[v1][r-1][v2] << endl;
	#endif

	return dp[v1][r-1][v2];
}

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;
      ^~~
# Verdict Execution time Memory Grader output
1 Correct 51 ms 12152 KB Output is correct
2 Incorrect 51 ms 12152 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 8184 KB Output is correct
2 Incorrect 12 ms 8184 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 8312 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 52 ms 16120 KB Output is correct
2 Correct 52 ms 16132 KB Output is correct
3 Correct 52 ms 16120 KB Output is correct
4 Correct 94 ms 17176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 8444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 8284 KB Output isn't correct
2 Halted 0 ms 0 KB -