답안 #1008088

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1008088 2024-06-26T07:32:38 Z overwatch9 자매 도시 (APIO20_swap) C++17
0 / 100
2000 ms 524288 KB
#include "swap.h"

#include <bits/stdc++.h>
using namespace std;

vector <vector <pair <int, int>>> adj;
vector <array <int, 3>> edges;
int n, m;
void init(int N, int M, vector<int> U, vector<int> V, vector<int> W) {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    adj.resize(N+1);
	n = N;
	m = M;
    for (int i = 0; i < M; i++) {
        adj[U[i]].push_back({V[i], W[i]});
		adj[V[i]].push_back({U[i], W[i]});
		edges.push_back({U[i], V[i], W[i]});
		edges.push_back({V[i], U[i], W[i]});
	}
}

int getMinimumFuelCapacity(int x, int y) {
	vector <vector <int>> dis(n, vector <int> (n, 1e9 + 1));
	dis[x][y] = 0;
	priority_queue <array <int, 3>> pq;
	pq.push({0, x, y});
	vector <vector <bool>> processed(n, vector <bool> (n));
	while (!pq.empty()) {
		int a = pq.top()[1], b = pq.top()[2];
		pq.pop();
		if (processed[a][b])
			continue;
		processed[a][b] = true;
		for (auto i : adj[a]) {
			for (auto j : adj[b]) {
				int d = max({dis[a][b], i.second, j.second});
				if (d < dis[i.first][j.first] && i.first != j.first && (i.first != b || j.first != a)) {
					dis[i.first][j.first] = d;
					pq.push({-d, i.first, j.first});
				}
				d = max(dis[a][b], i.second);
				if (d < dis[i.first][b] && i.first != b) {
					dis[i.first][b] = d;
					pq.push({-d, i.first, b});
				}
				d = max(dis[a][b], j.second);
				if (d < dis[a][j.first] && a != j.first) {
					dis[a][j.first] = d;
					pq.push({-d, a, j.first});
				}
			}
		}
	}
	if (dis[y][x] == 1e9 + 1)
		dis[y][x] = -1;
	return dis[y][x];
}
// int main() {
// 	int N, M;
// 	cin >> N >> M;
// 	vector <int> u(M), v(M), w(M);
// 	for (int i = 0; i < M; i++)
// 		cin >> u[i] >> v[i] >> w[i];
// 	init(N, M, u, v, w);
// 	int q;
// 	cin >> q;
// 	while (q--) {
// 		int x, y;
// 		cin >> x >> y;
// 		cout << getMinimumFuelCapacity(x, y) << '\n';
// 	}
// }
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 67 ms 1756 KB Output is correct
5 Correct 335 ms 6400 KB Output is correct
6 Correct 292 ms 6160 KB Output is correct
7 Correct 412 ms 7736 KB Output is correct
8 Correct 433 ms 5996 KB Output is correct
9 Runtime error 249 ms 524288 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Runtime error 248 ms 524288 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 67 ms 1756 KB Output is correct
5 Correct 335 ms 6400 KB Output is correct
6 Correct 292 ms 6160 KB Output is correct
7 Correct 412 ms 7736 KB Output is correct
8 Correct 433 ms 5996 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 761 ms 12064 KB Output is correct
11 Correct 759 ms 7652 KB Output is correct
12 Correct 751 ms 9832 KB Output is correct
13 Correct 537 ms 7792 KB Output is correct
14 Correct 565 ms 5984 KB Output is correct
15 Correct 727 ms 6108 KB Output is correct
16 Correct 689 ms 6944 KB Output is correct
17 Correct 739 ms 7256 KB Output is correct
18 Correct 841 ms 11056 KB Output is correct
19 Correct 548 ms 13680 KB Output is correct
20 Correct 769 ms 10196 KB Output is correct
21 Correct 1051 ms 15052 KB Output is correct
22 Correct 420 ms 6348 KB Output is correct
23 Correct 643 ms 8524 KB Output is correct
24 Execution timed out 2036 ms 41972 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 67 ms 1756 KB Output is correct
6 Correct 335 ms 6400 KB Output is correct
7 Correct 292 ms 6160 KB Output is correct
8 Correct 412 ms 7736 KB Output is correct
9 Correct 433 ms 5996 KB Output is correct
10 Runtime error 249 ms 524288 KB Execution killed with signal 9
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 67 ms 1756 KB Output is correct
5 Correct 335 ms 6400 KB Output is correct
6 Correct 292 ms 6160 KB Output is correct
7 Correct 412 ms 7736 KB Output is correct
8 Correct 433 ms 5996 KB Output is correct
9 Runtime error 249 ms 524288 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 67 ms 1756 KB Output is correct
6 Correct 335 ms 6400 KB Output is correct
7 Correct 292 ms 6160 KB Output is correct
8 Correct 412 ms 7736 KB Output is correct
9 Correct 433 ms 5996 KB Output is correct
10 Runtime error 249 ms 524288 KB Execution killed with signal 9
11 Halted 0 ms 0 KB -