Submission #358622

# Submission time Handle Problem Language Result Execution time Memory
358622 2021-01-26T02:17:46 Z amunduzbaev Wombats (IOI13_wombats) C++14
27 / 100
227 ms 73728 KB
#include "wombats.h"

#ifndef EVAL
#include "grader.cpp"
#endif 

#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define ff first
#define ss second

const int N = 5e3+5;

vector<pair<int, int>> edges[N*200];
int n, m;
int res[2][2];

int h[N][N], v[N][N];

#define ll long long

ll sum = 0;
int dp[2][N];
const ll inf = 1e9+7;

void recalc(){
	//cout<<"\n______\n";
	for(int i=0;i<n;i++) dp[0][i] = dp[1][i] = inf;
	dp[0][0] = 0;
	dp[1][0] = h[0][0];
	//cout<<dp[0][0]<<" "<<dp[1][0]<<"\n";
	
	for(int i=1;i<n;i++){
		dp[0][i] = dp[0][i-1] + v[i-1][0]; //, dp[1][i] + h[i][0]);
		dp[1][i] = dp[1][i-1] + v[i-1][1]; //, dp[0][i] + h[i][0]);
		dp[0][i] = min(dp[0][i], dp[1][i] + h[i][0]);
		dp[1][i] = min(dp[1][i], dp[0][i] + h[i][0]);
		//cout<<dp[0][i]<<" "<<dp[1][i]<<"\n";
	}
	res[0][0] = dp[0][n-1], res[0][1] = dp[1][n-1];
	//cout<<"\n______\n";
	
	
	for(int i=0;i<n;i++) dp[0][i] = dp[1][i] = inf;
	dp[1][0] = 0;
	dp[0][0] = h[0][0];
	//cout<<dp[0][0]<<" "<<dp[1][0]<<"\n";
	for(int i=1;i<n;i++){
		dp[0][i] = dp[0][i-1] + v[i-1][0]; //, dp[1][i] + h[i][0]);
		dp[1][i] = dp[1][i-1] + v[i-1][1]; //, dp[0][i] + h[i][0]);
		dp[0][i] = min(dp[0][i], dp[1][i] + h[i][0]);
		dp[1][i] = min(dp[1][i], dp[0][i] + h[i][0]);
		//cout<<dp[0][i]<<" "<<dp[1][i]<<"\n";
	}
	res[1][0] = dp[0][n-1], res[1][1] = dp[1][n-1];
	
}

void init(int R, int C, int H[5000][200], int V[5000][200]) {
    n = R, m = C;
    for(int i=0;i<n-1;i++){
		for(int j=0;j<m;j++) v[i][j] = V[i][j], sum += v[i][j];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m-1;j++) h[i][j] = H[i][j];
	}
	recalc();
}


void changeH(int p, int q, int w) {
	sum -= h[p][q];
	h[p][q] = w;
	sum += w;
	recalc();
}

void changeV(int p, int q, int w) {
    sum -= v[p][q];
    v[p][q] = w;
    sum += w;
    recalc();
}

const ll mod = 1e18+7;

int escape(int V1, int V2) {
	if(m == 1) return sum;
	return res[V1][V2];
}

/*

3 2
5
3
8
9 4 
4 3 
4
3 0 1
3 0 0
3 1 0
3 1 1 

*/

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;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 141 ms 48236 KB Output is correct
2 Correct 143 ms 48212 KB Output is correct
3 Correct 227 ms 49872 KB Output is correct
4 Correct 142 ms 48108 KB Output is correct
5 Correct 144 ms 48108 KB Output is correct
6 Correct 16 ms 23788 KB Output is correct
7 Correct 17 ms 23916 KB Output is correct
8 Correct 17 ms 23788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 23788 KB Output is correct
2 Correct 16 ms 23788 KB Output is correct
3 Correct 16 ms 23788 KB Output is correct
4 Incorrect 17 ms 24064 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 24812 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 175 ms 72136 KB Output is correct
2 Correct 177 ms 72172 KB Output is correct
3 Correct 176 ms 72108 KB Output is correct
4 Correct 218 ms 73728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 24812 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 24812 KB Output isn't correct
2 Halted 0 ms 0 KB -