답안 #60249

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
60249 2018-07-23T22:28:01 Z spencercompton 웜뱃 (IOI13_wombats) C++17
55 / 100
20000 ms 18220 KB
#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;
int bel[5000][200];
int rig[5000][200];
int r, c;
bool v[5000][200];
pair<int, int> pre[200][200];
int upd = 0;
int sum = 0;
int vals[2][2];
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++){
			if(i+1<r){
				bel[i][j] = V[i][j];
				sum += V[i][j];
			}
			if(j+1<c){
				rig[i][j] = H[i][j];
			}
		}
	}
	for(int i = 0; i<c; i++){
		for(int j = 0; j<c; j++){
			pre[i][j] = make_pair(-1,-1);
		}
	}
}
 
void changeH(int P, int Q, int W) {
	rig[P][Q] = W;
	upd++;
}
 
void changeV(int P, int Q, int W) {
	sum += (W-bel[P][Q]);
	bel[P][Q] = W;
	upd++;
}
 
int escape(int V1, int V2) {
	if(c==1){
		return sum;
	}
	if(pre[V1][V2].second==upd){
		return pre[V1][V2].first;
	}
	for(int i = 0; i<r; i++){
		for(int j = 0; j<c; j++){
			v[i][j] = false;
		}
	}
	priority_queue<pair<int, pair<int, int> > > pq;
	pq.push(make_pair(0,make_pair(0,V1)));
	while(pq.size()>0){
		int zz = -pq.top().first;
		int y = pq.top().second.first;
		int x = pq.top().second.second;
		pq.pop();
		if(y==r-1 && x==V2){
			pre[V1][V2] = make_pair(zz,upd);
			return zz;
		}
		if(v[y][x]){
			continue;
		}
		v[y][x] = true;
		int ny, nx;
		if(x>0){
			 ny = y;
			 nx = x-1; 
			if(!v[ny][nx]){
				pq.push(make_pair(-zz-rig[ny][nx],make_pair(ny,nx)));
			}
		}
		if(x<c-1){
			 ny = y;
			 nx = x+1;
			if(!v[ny][nx]){
				pq.push(make_pair(-zz-rig[y][x],make_pair(ny,nx)));
			}
		}
		if(y<r-1){
			 ny = y+1;
			 nx = x;
			if(!v[ny][nx]){
				pq.push(make_pair(-zz-bel[y][x],make_pair(ny,nx)));

			}
		}
	}
    return -1;
}

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 11 ms 8184 KB Output is correct
2 Correct 11 ms 8184 KB Output is correct
3 Correct 144 ms 9760 KB Output is correct
4 Correct 10 ms 9760 KB Output is correct
5 Correct 12 ms 9760 KB Output is correct
6 Correct 2 ms 9760 KB Output is correct
7 Correct 2 ms 9760 KB Output is correct
8 Correct 3 ms 9760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 9760 KB Output is correct
2 Correct 3 ms 9760 KB Output is correct
3 Correct 3 ms 9760 KB Output is correct
4 Correct 19 ms 9760 KB Output is correct
5 Correct 4 ms 9760 KB Output is correct
6 Correct 27 ms 9760 KB Output is correct
7 Correct 24 ms 9760 KB Output is correct
8 Correct 22 ms 9760 KB Output is correct
9 Correct 28 ms 9760 KB Output is correct
10 Correct 26 ms 9760 KB Output is correct
11 Correct 110 ms 9760 KB Output is correct
12 Correct 28 ms 9760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 266 ms 9760 KB Output is correct
2 Correct 181 ms 9760 KB Output is correct
3 Correct 218 ms 9760 KB Output is correct
4 Correct 221 ms 9760 KB Output is correct
5 Correct 282 ms 9760 KB Output is correct
6 Correct 2 ms 9760 KB Output is correct
7 Correct 2 ms 9760 KB Output is correct
8 Correct 2 ms 9760 KB Output is correct
9 Correct 263 ms 9760 KB Output is correct
10 Correct 3 ms 9760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1059 ms 17304 KB Output is correct
2 Correct 2200 ms 17312 KB Output is correct
3 Correct 1158 ms 17312 KB Output is correct
4 Correct 1839 ms 18204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 224 ms 18204 KB Output is correct
2 Correct 175 ms 18204 KB Output is correct
3 Correct 230 ms 18204 KB Output is correct
4 Correct 232 ms 18204 KB Output is correct
5 Correct 252 ms 18204 KB Output is correct
6 Correct 897 ms 18204 KB Output is correct
7 Correct 1889 ms 18204 KB Output is correct
8 Correct 978 ms 18204 KB Output is correct
9 Correct 1947 ms 18220 KB Output is correct
10 Correct 9 ms 18220 KB Output is correct
11 Correct 9 ms 18220 KB Output is correct
12 Correct 80 ms 18220 KB Output is correct
13 Correct 9 ms 18220 KB Output is correct
14 Correct 9 ms 18220 KB Output is correct
15 Correct 2 ms 18220 KB Output is correct
16 Correct 2 ms 18220 KB Output is correct
17 Correct 2 ms 18220 KB Output is correct
18 Correct 20 ms 18220 KB Output is correct
19 Correct 4 ms 18220 KB Output is correct
20 Correct 29 ms 18220 KB Output is correct
21 Correct 21 ms 18220 KB Output is correct
22 Correct 25 ms 18220 KB Output is correct
23 Correct 28 ms 18220 KB Output is correct
24 Correct 29 ms 18220 KB Output is correct
25 Correct 114 ms 18220 KB Output is correct
26 Correct 31 ms 18220 KB Output is correct
27 Correct 273 ms 18220 KB Output is correct
28 Execution timed out 20076 ms 18220 KB Time limit exceeded
29 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 211 ms 18220 KB Output is correct
2 Correct 177 ms 18220 KB Output is correct
3 Correct 235 ms 18220 KB Output is correct
4 Correct 247 ms 18220 KB Output is correct
5 Correct 228 ms 18220 KB Output is correct
6 Correct 1101 ms 18220 KB Output is correct
7 Correct 2542 ms 18220 KB Output is correct
8 Correct 1067 ms 18220 KB Output is correct
9 Correct 2276 ms 18220 KB Output is correct
10 Correct 9 ms 18220 KB Output is correct
11 Correct 8 ms 18220 KB Output is correct
12 Correct 80 ms 18220 KB Output is correct
13 Correct 8 ms 18220 KB Output is correct
14 Correct 8 ms 18220 KB Output is correct
15 Correct 1641 ms 18220 KB Output is correct
16 Execution timed out 20085 ms 18220 KB Time limit exceeded
17 Halted 0 ms 0 KB -