답안 #123082

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
123082 2019-06-30T07:51:36 Z Mahdi_Jfri 웜뱃 (IOI13_wombats) C++14
55 / 100
20000 ms 209216 KB
#include "wombats.h"
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back

const int maxn = 5e3 + 20;
const int maxm = 1e2 + 20;
const int maxv = maxn * maxm;
const int maxe = maxn * maxm * 2;

int wH[maxn][maxm] , wV[maxn][maxm] , id;

int d[maxm][maxv] , n , m;
bool have[maxm];

int cd(int a , int b)
{
	return a * m + b;
}

void dij(int src)
{
	if(have[src])
		return;

	have[src] = 1;
	fill(d[src] , d[src] + m , 1e9);
	d[src][src] = 0;

	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j + 1 < m; j++)
		{
			int v = cd(i , j) , u = cd(i , j + 1);
			d[src][u] = min(d[src][u] , d[src][v] + wH[i][j]);
			d[src][v] = min(d[src][v] , d[src][u] + wH[i][j]);
		}

		for(int j = m - 2; j >= 0; j--)
		{
			int v = cd(i , j) , u = cd(i , j + 1);
			d[src][u] = min(d[src][u] , d[src][v] + wH[i][j]);
			d[src][v] = min(d[src][v] , d[src][u] + wH[i][j]);
		}

		if(i + 1 < n)
			for(int j = 0; j < m; j++)
				d[src][cd(i + 1 , j)] = d[src][cd(i , j)] + wV[i][j];
	}
}

void init(int R, int C, int H[5000][200], int V[5000][200])
{
	n = R , m = C;

	for(int i = 0; i < n; i++)
		for(int j = 0; j + 1 < m; j++)
			wH[i][j] = H[i][j];	

	for(int i = 0; i + 1 < n; i++)
		for(int j = 0; j < m; j++)
			wV[i][j] = V[i][j];
}

void changeH(int P, int Q, int W)
{
	wH[P][Q] = W;
	memset(have , 0 , sizeof have);
}

void changeV(int P, int Q, int W)
{
	wV[P][Q] = W;
	memset(have , 0 , sizeof have);
}

int escape(int V1, int V2)
{
	dij(V1);
	return d[V1][cd(n - 1 , V2)];
}

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;
      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 6648 KB Output is correct
2 Correct 19 ms 6648 KB Output is correct
3 Correct 89 ms 8188 KB Output is correct
4 Correct 19 ms 6648 KB Output is correct
5 Correct 19 ms 6648 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 368 KB Output is correct
4 Correct 2 ms 632 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 632 KB Output is correct
7 Correct 2 ms 632 KB Output is correct
8 Correct 2 ms 632 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 632 KB Output is correct
11 Correct 79 ms 1528 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 3832 KB Output is correct
2 Correct 14 ms 3448 KB Output is correct
3 Correct 15 ms 3576 KB Output is correct
4 Correct 16 ms 3604 KB Output is correct
5 Correct 15 ms 3576 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 8 ms 632 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 93 ms 13048 KB Output is correct
2 Correct 96 ms 12980 KB Output is correct
3 Correct 89 ms 13112 KB Output is correct
4 Correct 136 ms 13804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 3704 KB Output is correct
2 Correct 15 ms 3448 KB Output is correct
3 Correct 15 ms 3548 KB Output is correct
4 Correct 16 ms 3576 KB Output is correct
5 Correct 16 ms 3576 KB Output is correct
6 Correct 89 ms 12980 KB Output is correct
7 Correct 89 ms 13012 KB Output is correct
8 Correct 89 ms 13012 KB Output is correct
9 Correct 125 ms 13712 KB Output is correct
10 Correct 18 ms 6648 KB Output is correct
11 Correct 19 ms 6648 KB Output is correct
12 Correct 88 ms 8184 KB Output is correct
13 Correct 19 ms 6648 KB Output is correct
14 Correct 18 ms 6568 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 504 KB Output is correct
19 Correct 2 ms 504 KB Output is correct
20 Correct 2 ms 632 KB Output is correct
21 Correct 2 ms 632 KB Output is correct
22 Correct 2 ms 632 KB Output is correct
23 Correct 2 ms 632 KB Output is correct
24 Correct 2 ms 632 KB Output is correct
25 Correct 78 ms 1784 KB Output is correct
26 Correct 2 ms 632 KB Output is correct
27 Correct 9 ms 732 KB Output is correct
28 Execution timed out 20109 ms 209216 KB Time limit exceeded
29 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 3704 KB Output is correct
2 Correct 15 ms 3448 KB Output is correct
3 Correct 15 ms 3576 KB Output is correct
4 Correct 15 ms 3576 KB Output is correct
5 Correct 15 ms 3660 KB Output is correct
6 Correct 89 ms 12920 KB Output is correct
7 Correct 88 ms 12980 KB Output is correct
8 Correct 98 ms 12984 KB Output is correct
9 Correct 127 ms 13688 KB Output is correct
10 Correct 18 ms 6648 KB Output is correct
11 Correct 19 ms 6648 KB Output is correct
12 Correct 90 ms 8332 KB Output is correct
13 Correct 21 ms 6652 KB Output is correct
14 Correct 19 ms 6648 KB Output is correct
15 Runtime error 266 ms 33920 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Halted 0 ms 0 KB -