# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1078961 | 2024-08-28T08:42:29 Z | Hanksburger | September (APIO24_september) | C++17 | 134 ms | 10448 KB |
#include "september.h" #include <bits/stdc++.h> using namespace std; set<int> buff[5], s; vector<int> p, tmp; int deg[100005]; void process(int u) { if (deg[u]) s.insert(u); else { deg[p[u]]--; while (!deg[p[u]] && s.find(p[u])!=s.end()) { u=p[u]; s.erase(u); deg[p[u]]--; } } } int solve(int n, int m, vector<int> P, vector<vector<int> > a) { p=P; for (int i=1; i<n; i++) deg[p[i]]++; int cnt=0; for (int i=0; i<=n-2; i++) { for (int j=0; j<m; j++) buff[j].insert(a[j][i]); int u=*buff[0].begin(), ok=1; while (1) { for (int j=1; j<m; j++) { if (buff[j].find(u)==buff[j].end()) { ok=0; break; } } if (!ok) break; tmp.push_back(u); for (int j=0; j<m; j++) buff[j].erase(u); if (buff[0].empty()) break; u=*buff[0].begin(); } if (buff[0].empty()) { for (int j=0; j<tmp.size(); j++) process(tmp[j]); tmp.clear(); if (s.empty()) cnt++; } } return cnt; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 452 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 472 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 1 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 2 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 396 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 452 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 1 ms | 348 KB | Output is correct |
18 | Correct | 1 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 1 ms | 348 KB | Output is correct |
21 | Correct | 1 ms | 472 KB | Output is correct |
22 | Correct | 1 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 348 KB | Output is correct |
24 | Correct | 1 ms | 348 KB | Output is correct |
25 | Correct | 2 ms | 348 KB | Output is correct |
26 | Correct | 1 ms | 396 KB | Output is correct |
27 | Correct | 1 ms | 348 KB | Output is correct |
28 | Correct | 1 ms | 348 KB | Output is correct |
29 | Correct | 1 ms | 348 KB | Output is correct |
30 | Correct | 2 ms | 344 KB | Output is correct |
31 | Correct | 2 ms | 344 KB | Output is correct |
32 | Correct | 1 ms | 348 KB | Output is correct |
33 | Correct | 1 ms | 548 KB | Output is correct |
34 | Correct | 2 ms | 344 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 134 ms | 10140 KB | Output is correct |
5 | Correct | 122 ms | 10112 KB | Output is correct |
6 | Correct | 112 ms | 10096 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 472 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 1 ms | 348 KB | Output is correct |
18 | Correct | 134 ms | 10140 KB | Output is correct |
19 | Correct | 122 ms | 10112 KB | Output is correct |
20 | Correct | 112 ms | 10096 KB | Output is correct |
21 | Correct | 109 ms | 9836 KB | Output is correct |
22 | Correct | 109 ms | 9956 KB | Output is correct |
23 | Correct | 119 ms | 10080 KB | Output is correct |
24 | Correct | 120 ms | 10132 KB | Output is correct |
25 | Correct | 114 ms | 9832 KB | Output is correct |
26 | Correct | 110 ms | 9868 KB | Output is correct |
27 | Correct | 114 ms | 10088 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 2 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 396 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 134 ms | 10140 KB | Output is correct |
8 | Correct | 122 ms | 10112 KB | Output is correct |
9 | Correct | 112 ms | 10096 KB | Output is correct |
10 | Correct | 79 ms | 10444 KB | Output is correct |
11 | Correct | 77 ms | 10440 KB | Output is correct |
12 | Correct | 78 ms | 10440 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 452 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 1 ms | 348 KB | Output is correct |
18 | Correct | 1 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 1 ms | 348 KB | Output is correct |
21 | Correct | 1 ms | 472 KB | Output is correct |
22 | Correct | 1 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 348 KB | Output is correct |
24 | Correct | 1 ms | 348 KB | Output is correct |
25 | Correct | 2 ms | 348 KB | Output is correct |
26 | Correct | 1 ms | 396 KB | Output is correct |
27 | Correct | 1 ms | 348 KB | Output is correct |
28 | Correct | 1 ms | 348 KB | Output is correct |
29 | Correct | 1 ms | 348 KB | Output is correct |
30 | Correct | 2 ms | 344 KB | Output is correct |
31 | Correct | 2 ms | 344 KB | Output is correct |
32 | Correct | 1 ms | 348 KB | Output is correct |
33 | Correct | 1 ms | 548 KB | Output is correct |
34 | Correct | 2 ms | 344 KB | Output is correct |
35 | Correct | 134 ms | 10140 KB | Output is correct |
36 | Correct | 122 ms | 10112 KB | Output is correct |
37 | Correct | 112 ms | 10096 KB | Output is correct |
38 | Correct | 109 ms | 9836 KB | Output is correct |
39 | Correct | 109 ms | 9956 KB | Output is correct |
40 | Correct | 119 ms | 10080 KB | Output is correct |
41 | Correct | 120 ms | 10132 KB | Output is correct |
42 | Correct | 114 ms | 9832 KB | Output is correct |
43 | Correct | 110 ms | 9868 KB | Output is correct |
44 | Correct | 114 ms | 10088 KB | Output is correct |
45 | Correct | 79 ms | 10444 KB | Output is correct |
46 | Correct | 77 ms | 10440 KB | Output is correct |
47 | Correct | 78 ms | 10440 KB | Output is correct |
48 | Correct | 102 ms | 10436 KB | Output is correct |
49 | Correct | 84 ms | 10448 KB | Output is correct |
50 | Correct | 110 ms | 10444 KB | Output is correct |
51 | Correct | 97 ms | 10440 KB | Output is correct |
52 | Correct | 78 ms | 10320 KB | Output is correct |
53 | Correct | 87 ms | 10420 KB | Output is correct |
54 | Correct | 79 ms | 10444 KB | Output is correct |