Submission #232147

# Submission time Handle Problem Language Result Execution time Memory
232147 2020-05-16T09:20:10 Z errorgorn Wombats (IOI13_wombats) C++14
55 / 100
20000 ms 262148 KB
#include <bits/stdc++.h>
#include "wombats.h"
using namespace std;

const int INF=1e9;

int r,c;
int h[5005][205];
int v[5005][205];

int data[17000][105][105];

int pre[205]; //save space ig
void build(int u,int pos){
	for (int x=1;x<c;x++){
		pre[x]=pre[x-1]+h[pos][x-1];
	}
	
	for (int x=0;x<c;x++){
		for (int y=0;y<c;y++){
			data[u][x][y]=pre[max(x,y)]-pre[min(x,y)]+v[pos][y];
		}
	}
}

void merge(int u){
	int l=u<<1,r=u<<1|1;
	
	for (int x=0;x<c;x++){
		for (int y=0;y<c;y++){
			data[u][x][y]=INF;
			for (int z=0;z<c;z++){
				data[u][x][y]=min(data[u][x][y],data[l][x][z]+data[r][z][y]);
			}
		}
	}
}

void init(int u,int s,int e){
	if (s==e){
		build(u,s);
	}
	else{
		int m=s+e>>1;
		init(u<<1,s,m);
		init(u<<1|1,m+1,e);
		
		merge(u);
	}
}

void update(int u,int i,int s,int e){
	if (s==e){
		build(u,s);
	}
	else{
		int m=s+e>>1;
		
		if (i<=m) update(u<<1,i,s,m);
		else update(u<<1|1,i,m+1,e);
		
		merge(u);
	}
}

void init(int R, int C, int H[5000][200], int V[5000][200]) {
	r=R,c=C;
	
    for (int x=0;x<r;x++){
		for (int y=0;y<c-1;y++){
			h[x][y]=H[x][y];
		}
	}
	
	for (int x=0;x<r-1;x++){
		for (int y=0;y<c;y++){
			v[x][y]=V[x][y];
		}
	}
	
	init(1,0,r-1);
}

void changeH(int P, int Q, int W) {
    h[P][Q]=W;
    update(1,P,0,r-1);
}

void changeV(int P, int Q, int W) {
    v[P][Q]=W;
    update(1,P,0,r-1);
}

int escape(int c1, int c2) {
    return data[1][c1][c2];
}

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 'void init(int, int, int)':
wombats.cpp:44:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int m=s+e>>1;
         ~^~
wombats.cpp: In function 'void update(int, int, int, int)':
wombats.cpp:57:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int m=s+e>>1;
         ~^~
# Verdict Execution time Memory Grader output
1 Correct 27 ms 49656 KB Output is correct
2 Correct 28 ms 49664 KB Output is correct
3 Correct 116 ms 52472 KB Output is correct
4 Correct 27 ms 49664 KB Output is correct
5 Correct 29 ms 49664 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 896 KB Output is correct
5 Correct 5 ms 896 KB Output is correct
6 Correct 5 ms 896 KB Output is correct
7 Correct 6 ms 896 KB Output is correct
8 Correct 5 ms 768 KB Output is correct
9 Correct 5 ms 896 KB Output is correct
10 Correct 5 ms 896 KB Output is correct
11 Correct 96 ms 2040 KB Output is correct
12 Correct 5 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1006 ms 9336 KB Output is correct
2 Correct 974 ms 9336 KB Output is correct
3 Correct 1006 ms 9464 KB Output is correct
4 Correct 1000 ms 9464 KB Output is correct
5 Correct 976 ms 9336 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4472 ms 9396 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 61692 KB Output is correct
2 Correct 35 ms 61696 KB Output is correct
3 Correct 35 ms 61816 KB Output is correct
4 Correct 79 ms 63096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1012 ms 9336 KB Output is correct
2 Correct 980 ms 9336 KB Output is correct
3 Correct 1004 ms 9464 KB Output is correct
4 Correct 1016 ms 9360 KB Output is correct
5 Correct 985 ms 9344 KB Output is correct
6 Correct 37 ms 61688 KB Output is correct
7 Correct 35 ms 61824 KB Output is correct
8 Correct 37 ms 61816 KB Output is correct
9 Correct 79 ms 63100 KB Output is correct
10 Correct 29 ms 49664 KB Output is correct
11 Correct 28 ms 49664 KB Output is correct
12 Correct 116 ms 52472 KB Output is correct
13 Correct 29 ms 49664 KB Output is correct
14 Correct 30 ms 49664 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 4 ms 384 KB Output is correct
18 Correct 5 ms 1024 KB Output is correct
19 Correct 5 ms 896 KB Output is correct
20 Correct 5 ms 896 KB Output is correct
21 Correct 5 ms 896 KB Output is correct
22 Correct 5 ms 896 KB Output is correct
23 Correct 5 ms 896 KB Output is correct
24 Correct 5 ms 896 KB Output is correct
25 Correct 95 ms 3320 KB Output is correct
26 Correct 5 ms 896 KB Output is correct
27 Correct 4497 ms 9440 KB Output is correct
28 Runtime error 3966 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1008 ms 9464 KB Output is correct
2 Correct 982 ms 9336 KB Output is correct
3 Correct 1000 ms 9464 KB Output is correct
4 Correct 1037 ms 9592 KB Output is correct
5 Correct 976 ms 9336 KB Output is correct
6 Correct 35 ms 61816 KB Output is correct
7 Correct 35 ms 61824 KB Output is correct
8 Correct 35 ms 61824 KB Output is correct
9 Correct 81 ms 63100 KB Output is correct
10 Correct 28 ms 49664 KB Output is correct
11 Correct 28 ms 49656 KB Output is correct
12 Correct 115 ms 52472 KB Output is correct
13 Correct 28 ms 49664 KB Output is correct
14 Correct 28 ms 49664 KB Output is correct
15 Execution timed out 20101 ms 207928 KB Time limit exceeded
16 Halted 0 ms 0 KB -