# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
136232 | 2019-07-25T04:19:40 Z | 송준혁(#3262) | Link (CEOI06_link) | C++14 | 527 ms | 15836 KB |
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int, int> pii; int N, K, ans; int M[505050]; int nx[505050], deg[505050]; priority_queue<pii> PQ; void f(int u, int d){ if (M[u] >= d) return; M[u] = d, deg[nx[u]]--; PQ.push(pii(-deg[nx[u]], nx[u])); f(nx[u], d-1); } int main(){ scanf("%d %d", &N, &K); for (int i=1; i<=N; i++){ int u, v; scanf("%d %d", &u, &v); nx[u] = v, deg[v]++; } for (int i=1; i<=N; i++) PQ.push(pii(-deg[i], i)); f(1, K+1); while (!PQ.empty()){ int u = PQ.top().second; PQ.pop(); if (M[u]) continue; f(u, K); ans++; } printf("%d\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Incorrect | 2 ms | 376 KB | Output isn't correct |
3 | Incorrect | 3 ms | 376 KB | Output isn't correct |
4 | Correct | 4 ms | 504 KB | Output is correct |
5 | Incorrect | 5 ms | 504 KB | Output isn't correct |
6 | Incorrect | 20 ms | 1396 KB | Output isn't correct |
7 | Incorrect | 33 ms | 1520 KB | Output isn't correct |
8 | Incorrect | 49 ms | 2152 KB | Output isn't correct |
9 | Correct | 76 ms | 4944 KB | Output is correct |
10 | Incorrect | 71 ms | 2664 KB | Output isn't correct |
11 | Correct | 128 ms | 4968 KB | Output is correct |
12 | Incorrect | 165 ms | 4836 KB | Output isn't correct |
13 | Incorrect | 207 ms | 8264 KB | Output isn't correct |
14 | Incorrect | 272 ms | 7004 KB | Output isn't correct |
15 | Correct | 335 ms | 9436 KB | Output is correct |
16 | Incorrect | 435 ms | 9308 KB | Output isn't correct |
17 | Incorrect | 472 ms | 15336 KB | Output isn't correct |
18 | Incorrect | 515 ms | 14616 KB | Output isn't correct |
19 | Incorrect | 510 ms | 14948 KB | Output isn't correct |
20 | Incorrect | 523 ms | 15580 KB | Output isn't correct |
21 | Incorrect | 511 ms | 15452 KB | Output isn't correct |
22 | Incorrect | 499 ms | 15836 KB | Output isn't correct |
23 | Incorrect | 513 ms | 15808 KB | Output isn't correct |
24 | Incorrect | 527 ms | 15836 KB | Output isn't correct |
25 | Incorrect | 519 ms | 15808 KB | Output isn't correct |