# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
732637 |
2023-04-29T07:05:41 Z |
flappybird |
None (JOI16_ho_t3) |
C++17 |
|
150 ms |
24104 KB |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define MAX 201010
#define MAXS 20
#define INF 1000000000000000001
#define bb ' '
#define ln '\n'
#define Ln '\n'
int dis[MAX];
vector<int> adj[MAX];
pii edges[MAX];
int ans[MAX];
int R[MAX];
int p[MAX];
vector<int> st[MAX];
int chk[MAX];
int sum[MAX];
int T[MAX];
int get_next(int v, int e) {
return edges[e].first + edges[e].second - v;
}
signed main() {
ios::sync_with_stdio(false), cin.tie(0);
int N, M, Q;
cin >> N >> M >> Q;
int i, a, b;
for (i = 1; i <= M; i++) cin >> a >> b, adj[a].push_back(i), adj[b].push_back(i), edges[i] = pii(a, b);
queue<int> q;
q.push(1);
dis[1] = 1;
while (q.size()) {
int t = q.front();
q.pop();
for (auto e : adj[t]) {
int v = get_next(t, e);
if (dis[v]) continue;
dis[v] = dis[t] + 1;
q.push(v);
}
}
for (i = 1; i <= M; i++) T[i] = Q + 10;
for (i = 1; i <= Q; i++) cin >> R[i], T[R[i]] = i - 1;
vector<int> vv;
for (i = 2; i <= N; i++) vv.push_back(i);
sort(vv.begin(), vv.end(), [&](int i, int j) {return dis[i] < dis[j]; });
ans[1] = Q + 10;
for (auto v : vv) {
for (auto e : adj[v]) {
int x = get_next(v, e);
if (dis[x] == dis[v] - 1) ans[v] = max(ans[v], min(ans[x], T[e]));
}
}
for (i = 2; i <= N; i++) sum[ans[i] + 1]++;
for (i = 1; i <= Q; i++) sum[i] += sum[i - 1], cout << sum[i] << ln;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
9684 KB |
Output is correct |
2 |
Correct |
6 ms |
9812 KB |
Output is correct |
3 |
Correct |
6 ms |
9924 KB |
Output is correct |
4 |
Correct |
5 ms |
9812 KB |
Output is correct |
5 |
Correct |
6 ms |
9792 KB |
Output is correct |
6 |
Correct |
7 ms |
9812 KB |
Output is correct |
7 |
Correct |
5 ms |
9812 KB |
Output is correct |
8 |
Correct |
5 ms |
9796 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
9684 KB |
Output is correct |
2 |
Correct |
6 ms |
9812 KB |
Output is correct |
3 |
Correct |
6 ms |
9924 KB |
Output is correct |
4 |
Correct |
5 ms |
9812 KB |
Output is correct |
5 |
Correct |
6 ms |
9792 KB |
Output is correct |
6 |
Correct |
7 ms |
9812 KB |
Output is correct |
7 |
Correct |
5 ms |
9812 KB |
Output is correct |
8 |
Correct |
5 ms |
9796 KB |
Output is correct |
9 |
Correct |
90 ms |
19936 KB |
Output is correct |
10 |
Correct |
108 ms |
19944 KB |
Output is correct |
11 |
Correct |
82 ms |
19720 KB |
Output is correct |
12 |
Correct |
90 ms |
19800 KB |
Output is correct |
13 |
Correct |
91 ms |
19876 KB |
Output is correct |
14 |
Correct |
86 ms |
19720 KB |
Output is correct |
15 |
Correct |
59 ms |
16868 KB |
Output is correct |
16 |
Correct |
51 ms |
16592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
108 ms |
17656 KB |
Output is correct |
2 |
Correct |
104 ms |
19992 KB |
Output is correct |
3 |
Correct |
74 ms |
19080 KB |
Output is correct |
4 |
Correct |
90 ms |
19788 KB |
Output is correct |
5 |
Correct |
89 ms |
19776 KB |
Output is correct |
6 |
Correct |
92 ms |
19680 KB |
Output is correct |
7 |
Correct |
55 ms |
16580 KB |
Output is correct |
8 |
Correct |
52 ms |
16448 KB |
Output is correct |
9 |
Correct |
36 ms |
15924 KB |
Output is correct |
10 |
Correct |
33 ms |
15972 KB |
Output is correct |
11 |
Correct |
120 ms |
20700 KB |
Output is correct |
12 |
Correct |
107 ms |
20044 KB |
Output is correct |
13 |
Correct |
108 ms |
19948 KB |
Output is correct |
14 |
Correct |
120 ms |
20544 KB |
Output is correct |
15 |
Correct |
117 ms |
20348 KB |
Output is correct |
16 |
Correct |
115 ms |
19876 KB |
Output is correct |
17 |
Correct |
125 ms |
20872 KB |
Output is correct |
18 |
Correct |
78 ms |
18500 KB |
Output is correct |
19 |
Correct |
122 ms |
23900 KB |
Output is correct |
20 |
Correct |
102 ms |
20800 KB |
Output is correct |
21 |
Correct |
74 ms |
17472 KB |
Output is correct |
22 |
Correct |
83 ms |
17424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
9684 KB |
Output is correct |
2 |
Correct |
6 ms |
9812 KB |
Output is correct |
3 |
Correct |
6 ms |
9924 KB |
Output is correct |
4 |
Correct |
5 ms |
9812 KB |
Output is correct |
5 |
Correct |
6 ms |
9792 KB |
Output is correct |
6 |
Correct |
7 ms |
9812 KB |
Output is correct |
7 |
Correct |
5 ms |
9812 KB |
Output is correct |
8 |
Correct |
5 ms |
9796 KB |
Output is correct |
9 |
Correct |
90 ms |
19936 KB |
Output is correct |
10 |
Correct |
108 ms |
19944 KB |
Output is correct |
11 |
Correct |
82 ms |
19720 KB |
Output is correct |
12 |
Correct |
90 ms |
19800 KB |
Output is correct |
13 |
Correct |
91 ms |
19876 KB |
Output is correct |
14 |
Correct |
86 ms |
19720 KB |
Output is correct |
15 |
Correct |
59 ms |
16868 KB |
Output is correct |
16 |
Correct |
51 ms |
16592 KB |
Output is correct |
17 |
Correct |
108 ms |
17656 KB |
Output is correct |
18 |
Correct |
104 ms |
19992 KB |
Output is correct |
19 |
Correct |
74 ms |
19080 KB |
Output is correct |
20 |
Correct |
90 ms |
19788 KB |
Output is correct |
21 |
Correct |
89 ms |
19776 KB |
Output is correct |
22 |
Correct |
92 ms |
19680 KB |
Output is correct |
23 |
Correct |
55 ms |
16580 KB |
Output is correct |
24 |
Correct |
52 ms |
16448 KB |
Output is correct |
25 |
Correct |
36 ms |
15924 KB |
Output is correct |
26 |
Correct |
33 ms |
15972 KB |
Output is correct |
27 |
Correct |
120 ms |
20700 KB |
Output is correct |
28 |
Correct |
107 ms |
20044 KB |
Output is correct |
29 |
Correct |
108 ms |
19948 KB |
Output is correct |
30 |
Correct |
120 ms |
20544 KB |
Output is correct |
31 |
Correct |
117 ms |
20348 KB |
Output is correct |
32 |
Correct |
115 ms |
19876 KB |
Output is correct |
33 |
Correct |
125 ms |
20872 KB |
Output is correct |
34 |
Correct |
78 ms |
18500 KB |
Output is correct |
35 |
Correct |
122 ms |
23900 KB |
Output is correct |
36 |
Correct |
102 ms |
20800 KB |
Output is correct |
37 |
Correct |
74 ms |
17472 KB |
Output is correct |
38 |
Correct |
83 ms |
17424 KB |
Output is correct |
39 |
Correct |
141 ms |
24104 KB |
Output is correct |
40 |
Correct |
150 ms |
23940 KB |
Output is correct |
41 |
Correct |
89 ms |
21020 KB |
Output is correct |
42 |
Correct |
124 ms |
23760 KB |
Output is correct |
43 |
Correct |
120 ms |
23800 KB |
Output is correct |
44 |
Correct |
124 ms |
23740 KB |
Output is correct |
45 |
Correct |
124 ms |
23620 KB |
Output is correct |
46 |
Correct |
75 ms |
18856 KB |
Output is correct |
47 |
Correct |
67 ms |
18516 KB |
Output is correct |
48 |
Correct |
63 ms |
18428 KB |
Output is correct |
49 |
Correct |
48 ms |
17504 KB |
Output is correct |
50 |
Correct |
46 ms |
17640 KB |
Output is correct |
51 |
Correct |
54 ms |
18104 KB |
Output is correct |
52 |
Correct |
48 ms |
18352 KB |
Output is correct |
53 |
Correct |
48 ms |
17436 KB |
Output is correct |
54 |
Correct |
46 ms |
17688 KB |
Output is correct |