Submission #232144

# Submission time Handle Problem Language Result Execution time Memory
232144 2020-05-16T09:14:57 Z errorgorn Wombats (IOI13_wombats) C++14
28 / 100
4802 ms 41336 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[10005][205][205];

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 Runtime error 60 ms 26872 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 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 6 ms 1152 KB Output is correct
5 Correct 6 ms 1152 KB Output is correct
6 Correct 5 ms 1152 KB Output is correct
7 Correct 6 ms 1152 KB Output is correct
8 Correct 5 ms 1152 KB Output is correct
9 Correct 5 ms 1152 KB Output is correct
10 Correct 5 ms 1152 KB Output is correct
11 Correct 92 ms 3576 KB Output is correct
12 Correct 5 ms 1152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1103 ms 17492 KB Output is correct
2 Correct 1045 ms 17144 KB Output is correct
3 Correct 1078 ms 17528 KB Output is correct
4 Correct 1082 ms 17528 KB Output is correct
5 Correct 1053 ms 17368 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4802 ms 17656 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 75 ms 41336 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1079 ms 17400 KB Output is correct
2 Correct 1062 ms 17272 KB Output is correct
3 Correct 1079 ms 17656 KB Output is correct
4 Correct 1083 ms 17528 KB Output is correct
5 Correct 1052 ms 17396 KB Output is correct
6 Runtime error 67 ms 41208 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1068 ms 17400 KB Output is correct
2 Correct 1065 ms 17288 KB Output is correct
3 Correct 1074 ms 17528 KB Output is correct
4 Correct 1083 ms 17784 KB Output is correct
5 Correct 1042 ms 17272 KB Output is correct
6 Runtime error 69 ms 41208 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Halted 0 ms 0 KB -