Submission #56503

# Submission time Handle Problem Language Result Execution time Memory
56503 2018-07-11T13:56:38 Z hamzqq9 Wombats (IOI13_wombats) C++14
28 / 100
10755 ms 258652 KB
#include "wombats.h"
#include<bits/stdc++.h>
#define lf double
#define ll long long
#define ull unsigned ll
#define ii pair<int,int>
#define li pair<ll,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define iiii2 pair<int,iii>
#define lii pair<ll,ii>
#define lolo pair<ll,ll>
#define heap priority_queue
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define all(x) x.begin(),x.end()
#define len(x) strlen(x)
#define sz(x) (int) x.size()
#define orta ((bas+son)/2)
#define min3(x,y,z) min(min(x,y),z)
#define max3(x,y,z) max(max(x,y),z)
#define umin(x,y) x=min(x,y)
#define umax(x,y) x=max(x,y)
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define MOD 1000000007
#define inf 2000000001
#define N 1000000005
#define LOG 20
#define magic 100
#define MAX 1000005
#define KOK 350
#define EPS 0.000000000001
#define pw(x) (1<<(x))
#define PI 3.1415926535
using namespace std;


struct SEG {

	int res[100][100];

} S[5000*2+600];

bool flag=false;
int H[5000][100],V[5000][100];
int R,C;

SEG merge(SEG A,SEG B) {

	SEG RES;

	for(int i=0;i<C;i++) {

		for(int j=0;j<C;j++) {

			RES.res[i][j]=inf;

			for(int k=0;k<C;k++) {

				umin(RES.res[i][j],A.res[i][k]+B.res[k][j]);

			}

		}

	}

	return RES;

}

int pre[2][100];

SEG create2(int bas) {

	SEG RES;

	pre[0][0]=pre[1][0]=0;

	for(int i=1;i<C;i++) {

		pre[0][i]=pre[0][i-1]+H[bas][i-1];

		pre[1][i]=pre[1][i-1]+H[bas+1][i-1];

	}

	for(int i=0;i<C;i++) {

		for(int j=0;j<C;j++) {

			RES.res[i][j]=inf;

			for(int k=0;k<C;k++) {

				umin(RES.res[i][j],V[bas][k]+abs(pre[0][k]-pre[0][i])+abs(pre[1][k]-pre[1][j]));

			}

			//printf("%d %d %d %d\n",bas,i,j,RES.res[i][j]);

		}

	}

	return RES;

}

void up(int node,int bas,int son,int x,int y) {

	if(bas>y || son<x) return ;

	if(son-bas==1) {

		S[node]=create2(bas);

		return ;

	}

	up(node*2,bas,orta,x,y);
	up(node*2+1,orta,son,x,y);

	S[node]=merge(S[node*2],S[node*2+1]);

}

void build(int node,int bas,int son) {

	if(bas+1==son) {

		S[node]=create2(bas);

		return ;

	}

	build(node*2,bas,orta);
	build(node*2+1,orta,son);

	S[node]=merge(S[node*2],S[node*2+1]);

}

void init(int R, int C, int H[5000][200], int V[5000][200]) {

	::R=R;
	::C=C;

	for(int i=0;i<R;i++) {

		for(int j=0;j<C;j++) {

			::H[i][j]=H[i][j];
			::V[i][j]=V[i][j];

		}

	}
	
	if(C>200) {

		flag=1;

		return ;

	}

	build(1,0,R-1);

}

void changeH(int P, int Q, int W) {
    
	H[P][Q]=W;

	if(flag) return ;

	up(1,0,R-1,P-1,P+1);

}

void changeV(int P, int Q, int W) {
    
	V[P][Q]=W;

	if(flag) return ;

	up(1,0,R-1,P,P+1);

}

int shp(int x,int y) {



}

int escape(int V1, int V2) {

	if(flag) return shp(V1,V2);

	return S[1].res[V1][V2];

}
/*
int h[5000][200],v[5000][200];

int main() {

	freopen("sample.in","r",stdin);

	int r,c;

	scanf("%d %d",&r,&c);

	for(int i=0;i<r;i++) {

		for(int j=0;j<c-1;j++) {

			scanf("%d",&h[i][j]);

		}

	}

	for(int i=0;i<r-1;i++) {

		for(int j=0;j<c;j++) {

			scanf("%d",&v[i][j]);

		}

	}

	init(r,c,h,v);

	int q;

	scanf("%d",&q);

	while(q--) {

		int t,x,y,z;

		scanf("%d",&t);

		if(t==1) {

			scanf("%d %d %d",&x,&y,&z);

			changeH(x,y,z);

		}
		else if(t==2){

			scanf("%d %d %d",&x,&y,&z);

			changeV(x,y,z);

		}
		else {

			scanf("%d %d",&x,&y);

			printf("%d\n",escape(x,y));

		}

	}

}*/

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 'int shp(int, int)':
wombats.cpp:204:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Runtime error 266 ms 250440 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 3 ms 250440 KB Output is correct
2 Correct 2 ms 250440 KB Output is correct
3 Correct 3 ms 250440 KB Output is correct
4 Correct 5 ms 250440 KB Output is correct
5 Correct 7 ms 250440 KB Output is correct
6 Correct 5 ms 250440 KB Output is correct
7 Correct 6 ms 250440 KB Output is correct
8 Correct 5 ms 250440 KB Output is correct
9 Correct 5 ms 250440 KB Output is correct
10 Correct 5 ms 250440 KB Output is correct
11 Correct 99 ms 250440 KB Output is correct
12 Correct 7 ms 250440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2308 ms 250440 KB Output is correct
2 Correct 1957 ms 250440 KB Output is correct
3 Correct 2323 ms 250440 KB Output is correct
4 Correct 2263 ms 250440 KB Output is correct
5 Correct 2377 ms 250440 KB Output is correct
6 Correct 3 ms 250440 KB Output is correct
7 Correct 3 ms 250440 KB Output is correct
8 Correct 3 ms 250440 KB Output is correct
9 Correct 10755 ms 250440 KB Output is correct
10 Correct 2 ms 250440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 292 ms 258652 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 2066 ms 258652 KB Output is correct
2 Correct 1951 ms 258652 KB Output is correct
3 Correct 2526 ms 258652 KB Output is correct
4 Correct 2245 ms 258652 KB Output is correct
5 Correct 2130 ms 258652 KB Output is correct
6 Runtime error 276 ms 258652 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 2349 ms 258652 KB Output is correct
2 Correct 2005 ms 258652 KB Output is correct
3 Correct 2267 ms 258652 KB Output is correct
4 Correct 1922 ms 258652 KB Output is correct
5 Correct 2003 ms 258652 KB Output is correct
6 Runtime error 268 ms 258652 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Halted 0 ms 0 KB -