답안 #897477

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
897477 2024-01-03T07:33:11 Z Muhammad_Aneeq 웜뱃 (IOI13_wombats) C++17
37 / 100
20000 ms 20060 KB
#include <queue>
#include "wombats.h"
#include <algorithm>
using namespace std;
int costy[5000][200],costx[5000][200];
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<C-1;i++)
		for (int j=0;j<R;j++)
			costx[j][i]=H[j][i];
	for (int i=0;i<R-1;i++)
		for (int j=0;j<C;j++)
			costy[i][j]=V[i][j];
}
int dist[5000][200]={};
bool check(int i,int j)
{
	if (i>=0&&i<r&&j>=0&&j<c)
		return 1;
	return 0;
}
void bfs(int i,int j)
{
	queue<pair<int,int>>Q;
	Q.push({i,j});
	dist[i][j]=0;
	while (Q.size())
	{
		int x,y;
		tie(x,y)=Q.front();
		Q.pop();
		if (check(x+1,y))
			if (dist[x+1][y]>dist[x][y]+costy[x][y])
			{
				dist[x+1][y]=dist[x][y]+costy[x][y];
				Q.push({x+1,y});
			}
		if (check(x,y+1))
			if (dist[x][y+1]>dist[x][y]+costx[x][y])
				{
					dist[x][y+1]=dist[x][y]+costx[x][y];
					Q.push({x,y+1});
				}
		if (check(x,y-1))
			if (dist[x][y-1]>dist[x][y]+costx[x][y-1])
				{
					dist[x][y-1]=dist[x][y]+costx[x][y-1];
					Q.push({x,y-1});
				}
	}
}
void changeH(int P, int Q, int W)
{
	costx[P][Q]=W;
}
void changeV(int P, int Q, int W)
{
	costy[P][Q]=W;
}
int escape(int V1, int V2)
{
	for (int i=0;i<r;i++)
		for (int j=0;j<c;j++)
			dist[i][j]=1e9+10;
	bfs(0,V1);
	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 42 ms 15888 KB Output is correct
2 Correct 42 ms 15708 KB Output is correct
3 Correct 15300 ms 18480 KB Output is correct
4 Correct 42 ms 15708 KB Output is correct
5 Correct 42 ms 15908 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 9 ms 8624 KB Output is correct
5 Correct 3 ms 8540 KB Output is correct
6 Correct 3 ms 8656 KB Output is correct
7 Correct 16 ms 8536 KB Output is correct
8 Correct 6 ms 8540 KB Output is correct
9 Correct 7 ms 8660 KB Output is correct
10 Correct 8 ms 8556 KB Output is correct
11 Correct 2790 ms 11244 KB Output is correct
12 Correct 67 ms 8536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 115 ms 8796 KB Output is correct
2 Correct 469 ms 8796 KB Output is correct
3 Correct 115 ms 8792 KB Output is correct
4 Correct 112 ms 8796 KB Output is correct
5 Correct 111 ms 8632 KB Output is correct
6 Correct 1 ms 6488 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 889 ms 8788 KB Output is correct
10 Correct 1 ms 8540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 20029 ms 20060 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 116 ms 8796 KB Output is correct
2 Correct 468 ms 8792 KB Output is correct
3 Correct 114 ms 8796 KB Output is correct
4 Correct 112 ms 8796 KB Output is correct
5 Correct 115 ms 8796 KB Output is correct
6 Execution timed out 20005 ms 20056 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 118 ms 8792 KB Output is correct
2 Correct 472 ms 8632 KB Output is correct
3 Correct 123 ms 8796 KB Output is correct
4 Correct 118 ms 8796 KB Output is correct
5 Correct 112 ms 8776 KB Output is correct
6 Execution timed out 20084 ms 20060 KB Time limit exceeded
7 Halted 0 ms 0 KB -