Submission #358362

# Submission time Handle Problem Language Result Execution time Memory
358362 2021-01-25T11:35:39 Z amunduzbaev Wombats (IOI13_wombats) C++14
0 / 100
12903 ms 249324 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[N][N];
const ll inf = 1e9+7;

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];
	}
	
	for(int s=0;s<m;s++){
		memset(dp, inf, sizeof dp);
		dp[s][0] = 0;
		dp[s][1] = h[0][0];
		for(int i=1;i<n;i++){
			dp[0][i] = dp[0][i-1] + v[i][0]; //, dp[1][i] + h[i][0]);
			dp[1][i] = dp[1][i-1] + v[i][0]; //, 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]);
		}
		res[s][0] = dp[0][n-1], res[s][1] = dp[1][n-1];
	}
}


void changeH(int p, int q, int w) {
	h[p][q] = w;
	for(int s=0;s<m;s++){
		memset(dp, inf, sizeof dp);
		dp[s][0] = 0;
		dp[s][1] = h[0][0];
		for(int i=1;i<n;i++){
			dp[0][i] = dp[0][i-1] + v[i][0]; //, dp[1][i] + h[i][0]);
			dp[1][i] = dp[1][i-1] + v[i][0]; //, 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]);
		}
		res[s][0] = dp[0][n-1], res[s][1] = dp[1][n-1];
	}
}

void changeV(int p, int q, int w) {
    v[p][q] = w;
    for(int s=0;s<m;s++){
		memset(dp, inf, sizeof dp);
		dp[s][0] = 0;
		dp[s^1][0] = h[0][0];
		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]);
		}
		res[s][0] = dp[0][n-1], res[s][1] = dp[1][n-1];
	}
}

const ll mod = 1e18+7;

int escape(int V1, int V2) {
	
	if(m == 1) return sum;
	
	return res[V1][V2];
    //priority_queue<pair<int, int>> qq;
	//qq.push({0, V1});
	//vector<ll> dis(n*m, mod);
	//dis[V1] = 0;
	
	//while(!qq.empty()){
		//int cur = qq.top().ss, dd = qq.top().ff; qq.pop();
		//if(dd > dis[cur]) continue;
		//for(auto x:edges[cur]){
			//if(dis[x.ff] > dis[cur] + x.ss){
				//dis[x.ff] = dis[cur] + x.ss;
				//qq.push({-dis[x.ff], x.ff});
			//}
		//}
	//}
	
	//return dis[m * (n-1) + V2];
}

/*

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]
   15 |  int res;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 6534 ms 146220 KB Output is correct
2 Incorrect 6600 ms 146284 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 68 ms 121964 KB Output is correct
2 Correct 66 ms 121836 KB Output is correct
3 Correct 67 ms 121836 KB Output is correct
4 Runtime error 492 ms 247304 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1530 ms 249252 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12903 ms 170140 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1534 ms 249324 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1559 ms 249196 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -