답안 #974683

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
974683 2024-05-03T15:58:20 Z XXBabaProBerkay 자매 도시 (APIO20_swap) C++17
37 / 100
2000 ms 20888 KB
#include "swap.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;

#define F first
#define S second

using ll = long long;

bool ans;
vector<bool> vis;
vector<vector<pair<int, int>>> adj;

void init(int N, int M, vector<int> U, vector<int> V, vector<int> W) //init(N, M, U, V, W)
{
	adj.resize(N);
	vis.resize(N);
	for (int i = 0; i < M; i++)
	{
		adj[U[i]].emplace_back(V[i], W[i]);
		adj[V[i]].emplace_back(U[i], W[i]);
	}
}

void DFS(int k, int p, int& s, int& t, int& x)
{
	if (vis[k])
	{
		ans = 1;
		return;
	}

	int c = 0;
	vis[k] = 1;
	for (auto i : adj[k])
		if (i.S <= x && i.F != p)
		{
			c++;
			DFS(i.F, k, s, t, x);
		}

	ans |= (k != t && k != s && c > 1);
}

int getMinimumFuelCapacity(int X, int Y)
{
	int l = 1, r = 1e9;
	while (l <= r)
	{
		int m = (l + r) >> 1;
		ans = 0;
		fill(vis.begin(), vis.end(), 0);

		DFS(X, X, X, Y, m);

		if (ans && vis[Y])
			r = m - 1;
		else
			l = m + 1;
	}

	return (l < 1e9 ? l : -1);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 436 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 448 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 140 ms 13236 KB Output is correct
10 Correct 291 ms 15188 KB Output is correct
11 Correct 422 ms 15496 KB Output is correct
12 Correct 391 ms 15548 KB Output is correct
13 Correct 555 ms 16572 KB Output is correct
14 Execution timed out 2061 ms 13752 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 436 KB Output is correct
3 Execution timed out 2041 ms 12936 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 436 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 448 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 2 ms 504 KB Output is correct
16 Correct 2 ms 564 KB Output is correct
17 Correct 2 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 2 ms 348 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 2 ms 604 KB Output is correct
25 Correct 2 ms 604 KB Output is correct
26 Correct 4 ms 604 KB Output is correct
27 Correct 2 ms 348 KB Output is correct
28 Correct 2 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 436 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 2 ms 448 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 140 ms 13236 KB Output is correct
11 Correct 291 ms 15188 KB Output is correct
12 Correct 422 ms 15496 KB Output is correct
13 Correct 391 ms 15548 KB Output is correct
14 Correct 555 ms 16572 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 2 ms 504 KB Output is correct
21 Correct 2 ms 564 KB Output is correct
22 Correct 2 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Correct 2 ms 348 KB Output is correct
27 Correct 2 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 2 ms 604 KB Output is correct
30 Correct 2 ms 604 KB Output is correct
31 Correct 4 ms 604 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 12 ms 1628 KB Output is correct
35 Correct 543 ms 14644 KB Output is correct
36 Correct 478 ms 12452 KB Output is correct
37 Correct 450 ms 10064 KB Output is correct
38 Correct 513 ms 9812 KB Output is correct
39 Correct 420 ms 9808 KB Output is correct
40 Correct 434 ms 9296 KB Output is correct
41 Correct 398 ms 13244 KB Output is correct
42 Correct 529 ms 13724 KB Output is correct
43 Correct 418 ms 16060 KB Output is correct
44 Correct 242 ms 10836 KB Output is correct
45 Correct 444 ms 14628 KB Output is correct
46 Correct 594 ms 14220 KB Output is correct
47 Correct 507 ms 10064 KB Output is correct
48 Correct 465 ms 11092 KB Output is correct
49 Correct 81 ms 11600 KB Output is correct
50 Correct 100 ms 9044 KB Output is correct
51 Correct 309 ms 12456 KB Output is correct
52 Correct 443 ms 17900 KB Output is correct
53 Correct 292 ms 16204 KB Output is correct
54 Correct 1315 ms 20888 KB Output is correct
55 Correct 611 ms 16008 KB Output is correct
56 Correct 682 ms 17184 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 436 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 448 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 140 ms 13236 KB Output is correct
10 Correct 291 ms 15188 KB Output is correct
11 Correct 422 ms 15496 KB Output is correct
12 Correct 391 ms 15548 KB Output is correct
13 Correct 555 ms 16572 KB Output is correct
14 Execution timed out 2061 ms 13752 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 436 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 2 ms 448 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 140 ms 13236 KB Output is correct
11 Correct 291 ms 15188 KB Output is correct
12 Correct 422 ms 15496 KB Output is correct
13 Correct 391 ms 15548 KB Output is correct
14 Correct 555 ms 16572 KB Output is correct
15 Execution timed out 2061 ms 13752 KB Time limit exceeded
16 Halted 0 ms 0 KB -