답안 #1074170

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1074170 2024-08-25T08:33:02 Z 1ne 웜뱃 (IOI13_wombats) C++14
21 / 100
20000 ms 9584 KB
#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;
struct node{
  int x,y,d;
};
vector<vector<vector<node>>>adj;
int dist3[200][200];
int n,m;
void init(int R, int C, int H[5000][200], int V[5000][200]) {
    /* ... */
    n = R,m = C;
   	adj.resize(R,vector<vector<node>>(C));
    for (int i = 0;i<R;++i){
    	for (int j = 0;j<C - 1;++j){
    		adj[i][j].push_back({i,j + 1,H[i][j]});
    		adj[i][j + 1].push_back({i,j,H[i][j]});
    	}
    }
    for (int i = 0;i<R - 1;++i){
    	for (int j = 0;j<C;++j){
    		adj[i][j].push_back({i + 1,j,V[i][j]});
    		adj[i + 1][j].push_back({i,j,V[i][j]});
    	}
    }
    for (int i = 0;i<m;++i){
    	for (int j = 0;j<n;++j){
    		for (int k = 0;k<m;++k){
    			dist3[i][k] = 1e9;
    		}
    	}
    }
	for (int i = 0;i<m;++i){
		vector<vector<int>>dist1(n,vector<int>(m,1e9));
		queue<pair<int,int>>q;
		q.push({0,i});
		dist1[0][i] = 0;
		while(!q.empty()){
			auto u = q.front();
			q.pop();
			for (auto x:adj[u.first][u.second]){
				if (u.first - x.x > 0)continue;
				if (dist1[x.x][x.y] > dist1[u.first][u.second] + x.d){
					dist1[x.x][x.y] = dist1[u.first][u.second] + x.d;
					q.push({x.x,x.y});
				}	
			}
		}
		for (int j = 0;j<C;++j){
			dist3[i][j] = dist1[n - 1][j];
		}
	}	
}

void changeH(int P, int Q, int W) {
	for (auto &x:adj[P][Q]){
		if (x.y == Q + 1){
			x.d = W;
		}
	}
	for (auto &x:adj[P][Q + 1]){
		if (x.y == Q){
			x.d = W;
		}
	}
	for (int i = 0;i<m;++i){
		vector<vector<int>>dist1(n,vector<int>(m,1e9));
		queue<pair<int,int>>q;
		q.push({0,i});
		dist1[0][i] = 0;
		while(!q.empty()){
			auto u = q.front();
			q.pop();
			for (auto x:adj[u.first][u.second]){
				if (u.first - x.x > 0)continue;
				if (dist1[x.x][x.y] > dist1[u.first][u.second] + x.d){
					dist1[x.x][x.y] = dist1[u.first][u.second] + x.d;
					q.push({x.x,x.y});
				}	
			}
		}
		for (int j = 0;j<m;++j){
			dist3[i][j] = dist1[n - 1][j];
		}
	}	    
}

void changeV(int P, int Q, int W) {
    for (auto &x:adj[P][Q]){
		if (x.x == P + 1){
			x.d = W;
		}
    }
    for (auto &x:adj[P + 1][Q]){
		if (x.x == P){
			x.d = W;
		}
	}
	
	for (int i = 0;i<m;++i){
		vector<vector<int>>dist1(n,vector<int>(m,1e9));
		queue<pair<int,int>>q;
		q.push({0,i});
		dist1[0][i] = 0;
		while(!q.empty()){
			auto u = q.front();
			q.pop();
			for (auto x:adj[u.first][u.second]){
				if (u.first - x.x > 0)continue;
				if (dist1[x.x][x.y] > dist1[u.first][u.second] + x.d){
					dist1[x.x][x.y] = dist1[u.first][u.second] + x.d;
					q.push({x.x,x.y});
				}	
			}
		}
		for (int j = 0;j<m;++j){
			dist3[i][j] = dist1[n - 1][j];
		}
	}
}

int escape(int V1, int V2) {
	return dist3[V1][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 129 ms 4952 KB Output is correct
2 Correct 151 ms 5036 KB Output is correct
3 Correct 183 ms 6480 KB Output is correct
4 Correct 131 ms 5036 KB Output is correct
5 Correct 138 ms 4956 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 2 ms 2392 KB Output is correct
5 Correct 2 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 2 ms 2396 KB Output is correct
8 Correct 2 ms 2396 KB Output is correct
9 Correct 1 ms 2488 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 51 ms 3520 KB Output is correct
12 Correct 6 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13031 ms 3540 KB Output is correct
2 Execution timed out 20045 ms 3616 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 20015 ms 9584 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12509 ms 3548 KB Output is correct
2 Execution timed out 20055 ms 1656 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12360 ms 3544 KB Output is correct
2 Execution timed out 20037 ms 3616 KB Time limit exceeded
3 Halted 0 ms 0 KB -