답안 #1074112

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1074112 2024-08-25T08:04:14 Z 1ne 웜뱃 (IOI13_wombats) C++14
12 / 100
230 ms 165712 KB
#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;
struct node{
  int x,y,d;
};
vector<vector<vector<node>>>adj;
int dist1[200][500][200];
int dist2[200][500][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<200;++i){
    	for (int j = 0;j<500;++j){
    		for (int k = 0;k<200;++k){
    			dist1[i][j][k] = 1e9;
    			dist2[i][j][k] = 1e9;
    		}
    	}
    }
	for (int i = 0;i<C;++i){
		queue<pair<int,int>>q;
		q.push({0,i});
		dist1[i][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[i][x.x][x.y] > dist1[i][u.first][u.second] + x.d){
					dist1[i][x.x][x.y] = dist1[i][u.first][u.second] + x.d;
					q.push({x.x,x.y});
				}	
			}
		}
	}
	for (int i = 0;i<C;++i){
		queue<pair<int,int>>q;
		q.push({R - 1,i});
		dist2[i][R - 1][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 (dist2[i][x.x][x.y] > dist2[i][u.first][u.second] + x.d){
					dist2[i][x.x][x.y] = dist2[i][u.first][u.second] + x.d;
					q.push({x.x,x.y});
				}	
			}
		}
	}
}

void changeH(int P, int Q, int W) {
    /* ... */
}

void changeV(int P, int Q, int W) {
    /* ... */
}

int escape(int V1, int V2) {
	return dist1[V1][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]
   15 |  int res;
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 86 ms 163152 KB Output is correct
2 Incorrect 80 ms 162980 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 158404 KB Output is correct
2 Correct 81 ms 158296 KB Output is correct
3 Correct 66 ms 158288 KB Output is correct
4 Correct 87 ms 160336 KB Output is correct
5 Correct 69 ms 160376 KB Output is correct
6 Correct 64 ms 160340 KB Output is correct
7 Correct 82 ms 160540 KB Output is correct
8 Correct 81 ms 160336 KB Output is correct
9 Correct 74 ms 160540 KB Output is correct
10 Correct 90 ms 160436 KB Output is correct
11 Correct 109 ms 161504 KB Output is correct
12 Correct 67 ms 160340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 208 ms 161468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 146 ms 165712 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 230 ms 161448 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 216 ms 161460 KB Output isn't correct
2 Halted 0 ms 0 KB -