Submission #933205

# Submission time Handle Problem Language Result Execution time Memory
933205 2024-02-25T09:05:18 Z zhaohaikun Airplane (NOI23_airplane) C++17
22 / 100
42 ms 13920 KB
// MagicDark
#include <bits/stdc++.h>
#define debug cerr << "[" << __LINE__ << "] "
#define SZ(x) (int) x.size() - 1
#define all(x) x.begin(), x.end()
#define ms(x, y) memset(x, y, sizeof x)
#define F(i, x, y) for (int i = (x); i <= (y); i++)
#define DF(i, x, y) for (int i = (x); i >= (y); i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> inline void chkmax(T& x, T y) {x = max(x, y);}
template <typename T> inline void chkmin(T& x, T y) {x = min(x, y);}
template <typename T> inline void read(T &x) {
	x = 0; int f = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	x *= f;
}
const int N = 2e5 + 10;
int n, m, a[N], f[2][N], ans = 2e9;
vector <int> v[N];
bool vis[N];
void dij(int t, int s) {
	ms(vis, false);
	priority_queue <pair <int, int>> q;
	q.emplace(f[t][s] = 0, s);
	while (q.size()) {
		int x = q.top().second; q.pop();
		if (vis[x]) continue;
		vis[x] = true;
		for (int i: v[x])
			if (max(a[i], f[t][x] + 1) < f[t][i]) q.emplace(f[t][i] = max(a[i], f[t][x] + 1), i);
	}
}
signed main() {
	read(n), read(m);
	F(i, 1, n) read(a[i]);
	F(i, 1, m) {
		int x, y; read(x), read(y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	ms(f, 0x3f);
	dij(0, 1), dij(1, n);
	F(i, 1, n) chkmin(ans, max(f[0][i], f[1][i]) * 2);
	F(i, 1, n)
		for (int j: v[i]) {
			// if (f[0][i] < f[1][i]) chkmin(ans, f[1][i] * 2 + 1);
			// else 
			chkmin(ans, max(f[0][i], f[1][j]) * 2 + 1);
		}
	cout << ans;
	return 0;
}
/* why?
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Correct 35 ms 13760 KB Output is correct
3 Correct 41 ms 13908 KB Output is correct
4 Correct 37 ms 13904 KB Output is correct
5 Correct 37 ms 13876 KB Output is correct
6 Correct 38 ms 13920 KB Output is correct
7 Correct 42 ms 13908 KB Output is correct
8 Correct 2 ms 6748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6808 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6748 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 2 ms 6976 KB Output is correct
7 Correct 2 ms 6748 KB Output is correct
8 Correct 2 ms 6748 KB Output is correct
9 Incorrect 3 ms 6748 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6808 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 1 ms 6748 KB Output is correct
4 Correct 1 ms 6748 KB Output is correct
5 Correct 1 ms 6748 KB Output is correct
6 Correct 2 ms 6976 KB Output is correct
7 Correct 2 ms 6748 KB Output is correct
8 Correct 2 ms 6748 KB Output is correct
9 Incorrect 3 ms 6748 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6744 KB Output is correct
2 Correct 35 ms 13760 KB Output is correct
3 Correct 41 ms 13908 KB Output is correct
4 Correct 37 ms 13904 KB Output is correct
5 Correct 37 ms 13876 KB Output is correct
6 Correct 38 ms 13920 KB Output is correct
7 Correct 42 ms 13908 KB Output is correct
8 Correct 2 ms 6748 KB Output is correct
9 Correct 2 ms 6808 KB Output is correct
10 Correct 1 ms 6748 KB Output is correct
11 Correct 1 ms 6748 KB Output is correct
12 Correct 1 ms 6748 KB Output is correct
13 Correct 1 ms 6748 KB Output is correct
14 Correct 2 ms 6976 KB Output is correct
15 Correct 2 ms 6748 KB Output is correct
16 Correct 2 ms 6748 KB Output is correct
17 Incorrect 3 ms 6748 KB Output isn't correct
18 Halted 0 ms 0 KB -