Submission #933203

# Submission time Handle Problem Language Result Execution time Memory
933203 2024-02-25T09:04:09 Z zhaohaikun Airplane (NOI23_airplane) C++17
32 / 100
1000 ms 17840 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];
void dij(int t, int s) {
	priority_queue <pair <int, int>> q;
	q.emplace(f[t][s] = 0, s);
	while (q.size()) {
		int x = q.top().second; q.pop();
		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 2 ms 6744 KB Output is correct
2 Correct 36 ms 16720 KB Output is correct
3 Correct 39 ms 17232 KB Output is correct
4 Correct 42 ms 17488 KB Output is correct
5 Correct 38 ms 17840 KB Output is correct
6 Correct 39 ms 17748 KB Output is correct
7 Correct 39 ms 17748 KB Output is correct
8 Correct 2 ms 6744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 2 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 6748 KB Output is correct
7 Correct 2 ms 6748 KB Output is correct
8 Correct 2 ms 6748 KB Output is correct
9 Correct 3 ms 6840 KB Output is correct
10 Correct 4 ms 6748 KB Output is correct
11 Correct 4 ms 6748 KB Output is correct
12 Correct 8 ms 6748 KB Output is correct
13 Correct 18 ms 6748 KB Output is correct
14 Correct 83 ms 6992 KB Output is correct
15 Correct 84 ms 6900 KB Output is correct
16 Correct 55 ms 6744 KB Output is correct
17 Correct 58 ms 7000 KB Output is correct
18 Correct 2 ms 6748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6748 KB Output is correct
2 Correct 1 ms 6748 KB Output is correct
3 Correct 2 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 6748 KB Output is correct
7 Correct 2 ms 6748 KB Output is correct
8 Correct 2 ms 6748 KB Output is correct
9 Correct 3 ms 6840 KB Output is correct
10 Correct 4 ms 6748 KB Output is correct
11 Correct 4 ms 6748 KB Output is correct
12 Correct 8 ms 6748 KB Output is correct
13 Correct 18 ms 6748 KB Output is correct
14 Correct 83 ms 6992 KB Output is correct
15 Correct 84 ms 6900 KB Output is correct
16 Correct 55 ms 6744 KB Output is correct
17 Correct 58 ms 7000 KB Output is correct
18 Correct 2 ms 6748 KB Output is correct
19 Correct 10 ms 6780 KB Output is correct
20 Correct 2 ms 6744 KB Output is correct
21 Correct 25 ms 6744 KB Output is correct
22 Correct 211 ms 6744 KB Output is correct
23 Correct 13 ms 6744 KB Output is correct
24 Correct 29 ms 6748 KB Output is correct
25 Correct 775 ms 6864 KB Output is correct
26 Correct 356 ms 6876 KB Output is correct
27 Execution timed out 1056 ms 6748 KB Time limit exceeded
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6744 KB Output is correct
2 Correct 36 ms 16720 KB Output is correct
3 Correct 39 ms 17232 KB Output is correct
4 Correct 42 ms 17488 KB Output is correct
5 Correct 38 ms 17840 KB Output is correct
6 Correct 39 ms 17748 KB Output is correct
7 Correct 39 ms 17748 KB Output is correct
8 Correct 2 ms 6744 KB Output is correct
9 Correct 1 ms 6748 KB Output is correct
10 Correct 1 ms 6748 KB Output is correct
11 Correct 2 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 6748 KB Output is correct
15 Correct 2 ms 6748 KB Output is correct
16 Correct 2 ms 6748 KB Output is correct
17 Correct 3 ms 6840 KB Output is correct
18 Correct 4 ms 6748 KB Output is correct
19 Correct 4 ms 6748 KB Output is correct
20 Correct 8 ms 6748 KB Output is correct
21 Correct 18 ms 6748 KB Output is correct
22 Correct 83 ms 6992 KB Output is correct
23 Correct 84 ms 6900 KB Output is correct
24 Correct 55 ms 6744 KB Output is correct
25 Correct 58 ms 7000 KB Output is correct
26 Correct 2 ms 6748 KB Output is correct
27 Correct 10 ms 6780 KB Output is correct
28 Correct 2 ms 6744 KB Output is correct
29 Correct 25 ms 6744 KB Output is correct
30 Correct 211 ms 6744 KB Output is correct
31 Correct 13 ms 6744 KB Output is correct
32 Correct 29 ms 6748 KB Output is correct
33 Correct 775 ms 6864 KB Output is correct
34 Correct 356 ms 6876 KB Output is correct
35 Execution timed out 1056 ms 6748 KB Time limit exceeded
36 Halted 0 ms 0 KB -