답안 #786061

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
786061 2023-07-18T01:15:37 Z MODDI 웜뱃 (IOI13_wombats) C++14
16 / 100
20000 ms 9412 KB
#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define ll long long
map<pair<pii,pii>, int> cost;
int r, c;
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-1; j++){
			cost[mp(mp(i,j), mp(i,j+1))] = H[i][j];
		}
	}
	for(int i = 0; i < R-1; i++){
		for(int j = 0; j < C; j++){
			cost[mp(mp(i,j), mp(i+1, j))] = V[i][j];
//			cout<<"COST: "<<i<<" "<<j<<" to "<<i+1<<" "<<j<<" is "<<V[i][j]<<endl;
		}
	}
}

void changeH(int P, int Q, int W) {
	cost[mp(mp(P,Q), mp(P,Q+1))] = W;
}

void changeV(int P, int Q, int W) {
	cost[mp(mp(P,Q), mp(P+1, Q))] = W;
}

int escape(int V1, int V2) {
	ll dist[r][c];
	for(int i = 0; i < r; i++)
		for(int j = 0; j < c; j++)
			dist[i][j] = 1e15;
	dist[0][V1] = 0;
	priority_queue<pair<int, pii> > pq;
	pq.push(mp(0, mp(0, V1)));
	while(!pq.empty()){
		pii at = pq.top().second;
		pq.pop();
		int x = at.first, y = at.second;
//		cout<<x<<" "<<y<<" "<<dist[x][y]<<endl;
		if(y - 1 >= 0 && dist[x][y-1] > dist[x][y] + cost[mp(mp(x,y-1), mp(x,y))]){
			dist[x][y-1] = dist[x][y] + cost[mp(mp(x,y-1), mp(x,y))];
			pq.push(mp(-dist[x][y-1], mp(x,y-1)));
		}
		if(y+1 < c && dist[x][y+1] > dist[x][y] + cost[mp(mp(x,y), mp(x,y+1))]){
			dist[x][y+1] = dist[x][y] + cost[mp(mp(x,y), mp(x,y+1))];
			pq.push(mp(-dist[x][y+1], mp(x,y+1)));
		}
//		cout<<dist[x+1][y]<<" "<<dist[x][y] + cost[mp(mp(x,y), mp(x+1,y))]<<endl;
		if(x + 1 < r && dist[x+1][y] > dist[x][y] + cost[mp(mp(x,y), mp(x+1,y))]){
			dist[x+1][y] = dist[x][y] + cost[mp(mp(x,y), mp(x+1, y))];
			pq.push(mp(-dist[x+1][y], mp(x+1, y)));
		}
	}
	return dist[r-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]
   15 |  int res;
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 303 ms 4544 KB Output is correct
2 Correct 313 ms 4564 KB Output is correct
3 Execution timed out 20008 ms 4840 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 61 ms 340 KB Output is correct
5 Correct 37 ms 380 KB Output is correct
6 Correct 45 ms 340 KB Output is correct
7 Correct 80 ms 340 KB Output is correct
8 Correct 43 ms 340 KB Output is correct
9 Correct 55 ms 340 KB Output is correct
10 Correct 48 ms 340 KB Output is correct
11 Execution timed out 20010 ms 2456 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 623 ms 1768 KB Output is correct
2 Correct 788 ms 2064 KB Output is correct
3 Correct 641 ms 1868 KB Output is correct
4 Correct 642 ms 1852 KB Output is correct
5 Correct 622 ms 1844 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 829 ms 1892 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2620 ms 9124 KB Output is correct
2 Correct 4113 ms 9192 KB Output is correct
3 Correct 2605 ms 9196 KB Output is correct
4 Execution timed out 20030 ms 9368 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 620 ms 1776 KB Output is correct
2 Correct 774 ms 2128 KB Output is correct
3 Correct 619 ms 1876 KB Output is correct
4 Correct 626 ms 1876 KB Output is correct
5 Correct 610 ms 1840 KB Output is correct
6 Correct 2567 ms 9196 KB Output is correct
7 Correct 4014 ms 9292 KB Output is correct
8 Correct 2582 ms 9188 KB Output is correct
9 Execution timed out 20050 ms 9412 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 628 ms 1764 KB Output is correct
2 Correct 797 ms 2140 KB Output is correct
3 Correct 630 ms 1944 KB Output is correct
4 Correct 633 ms 1856 KB Output is correct
5 Correct 610 ms 1856 KB Output is correct
6 Correct 2580 ms 9200 KB Output is correct
7 Correct 4094 ms 9192 KB Output is correct
8 Correct 2622 ms 9196 KB Output is correct
9 Execution timed out 20040 ms 9400 KB Time limit exceeded
10 Halted 0 ms 0 KB -