Submission #994824

# Submission time Handle Problem Language Result Execution time Memory
994824 2024-06-08T06:54:59 Z ducksaysquack September (APIO24_september) C++17
100 / 100
422 ms 12416 KB
#include "september.h"
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> adj(1e5+5); 
vector<bool> vis(1e5+5);
vector<int> p(1e5+5);
int c = -1;
void dfs(int u) {
	if(vis[u]) return;
	vis[u] = true; c = max(c, p[u]);
	for(auto i:adj[u]) dfs(i);
}
int solve(int n, int m, vector<int> f, vector<vector<int>> s) {
	for(int i=1;i<n;i++) adj[f[i]].push_back(i);
	for(int j=0;j<m;j++) for(int i=0;i<n-1;i++) p[s[j][i]] = max(p[s[j][i]], i);
	int ans = 0;
	for(int i=0;i<n-1;i++) for(int j=0;j<m;j++) {if(i > c && j == 0) ans++; dfs(s[j][i]);}
	for(int i=0;i<adj.size();i++) adj[i].clear(); fill(begin(vis),end(vis),0); fill(begin(p),end(p),0);
	c = -1;
	return ans;
}

Compilation message

september.cpp: In function 'int solve(int, int, std::vector<int>, std::vector<std::vector<int> >)':
september.cpp:18:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |  for(int i=0;i<adj.size();i++) adj[i].clear(); fill(begin(vis),end(vis),0); fill(begin(p),end(p),0);
      |              ~^~~~~~~~~~~
september.cpp:18:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   18 |  for(int i=0;i<adj.size();i++) adj[i].clear(); fill(begin(vis),end(vis),0); fill(begin(p),end(p),0);
      |  ^~~
september.cpp:18:48: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   18 |  for(int i=0;i<adj.size();i++) adj[i].clear(); fill(begin(vis),end(vis),0); fill(begin(p),end(p),0);
      |                                                ^~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3164 KB Output is correct
2 Correct 2 ms 3216 KB Output is correct
3 Correct 2 ms 3164 KB Output is correct
4 Correct 2 ms 3164 KB Output is correct
5 Correct 2 ms 3164 KB Output is correct
6 Correct 2 ms 3164 KB Output is correct
7 Correct 2 ms 3416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3164 KB Output is correct
2 Correct 2 ms 3216 KB Output is correct
3 Correct 2 ms 3164 KB Output is correct
4 Correct 2 ms 3164 KB Output is correct
5 Correct 2 ms 3164 KB Output is correct
6 Correct 2 ms 3164 KB Output is correct
7 Correct 2 ms 3416 KB Output is correct
8 Correct 2 ms 3164 KB Output is correct
9 Correct 4 ms 3164 KB Output is correct
10 Correct 2 ms 3160 KB Output is correct
11 Correct 2 ms 3160 KB Output is correct
12 Correct 2 ms 3164 KB Output is correct
13 Correct 2 ms 3164 KB Output is correct
14 Correct 2 ms 3164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3164 KB Output is correct
2 Correct 9 ms 3156 KB Output is correct
3 Correct 10 ms 3164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3164 KB Output is correct
2 Correct 2 ms 3216 KB Output is correct
3 Correct 2 ms 3164 KB Output is correct
4 Correct 2 ms 3164 KB Output is correct
5 Correct 2 ms 3164 KB Output is correct
6 Correct 2 ms 3164 KB Output is correct
7 Correct 2 ms 3416 KB Output is correct
8 Correct 8 ms 3164 KB Output is correct
9 Correct 9 ms 3156 KB Output is correct
10 Correct 10 ms 3164 KB Output is correct
11 Correct 8 ms 3160 KB Output is correct
12 Correct 9 ms 3164 KB Output is correct
13 Correct 9 ms 3164 KB Output is correct
14 Correct 8 ms 3260 KB Output is correct
15 Correct 8 ms 3220 KB Output is correct
16 Correct 8 ms 3164 KB Output is correct
17 Correct 10 ms 3260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3164 KB Output is correct
2 Correct 9 ms 3156 KB Output is correct
3 Correct 10 ms 3164 KB Output is correct
4 Correct 9 ms 3164 KB Output is correct
5 Correct 9 ms 3160 KB Output is correct
6 Correct 9 ms 3164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3164 KB Output is correct
2 Correct 2 ms 3216 KB Output is correct
3 Correct 2 ms 3164 KB Output is correct
4 Correct 2 ms 3164 KB Output is correct
5 Correct 2 ms 3164 KB Output is correct
6 Correct 2 ms 3164 KB Output is correct
7 Correct 2 ms 3416 KB Output is correct
8 Correct 2 ms 3164 KB Output is correct
9 Correct 4 ms 3164 KB Output is correct
10 Correct 2 ms 3160 KB Output is correct
11 Correct 2 ms 3160 KB Output is correct
12 Correct 2 ms 3164 KB Output is correct
13 Correct 2 ms 3164 KB Output is correct
14 Correct 2 ms 3164 KB Output is correct
15 Correct 8 ms 3164 KB Output is correct
16 Correct 9 ms 3156 KB Output is correct
17 Correct 10 ms 3164 KB Output is correct
18 Correct 8 ms 3160 KB Output is correct
19 Correct 9 ms 3164 KB Output is correct
20 Correct 9 ms 3164 KB Output is correct
21 Correct 8 ms 3260 KB Output is correct
22 Correct 8 ms 3220 KB Output is correct
23 Correct 8 ms 3164 KB Output is correct
24 Correct 10 ms 3260 KB Output is correct
25 Correct 9 ms 3164 KB Output is correct
26 Correct 9 ms 3160 KB Output is correct
27 Correct 9 ms 3164 KB Output is correct
28 Correct 9 ms 3164 KB Output is correct
29 Correct 9 ms 3220 KB Output is correct
30 Correct 9 ms 3164 KB Output is correct
31 Correct 10 ms 3164 KB Output is correct
32 Correct 9 ms 3224 KB Output is correct
33 Correct 9 ms 3160 KB Output is correct
34 Correct 9 ms 3164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3164 KB Output is correct
2 Correct 9 ms 3156 KB Output is correct
3 Correct 10 ms 3164 KB Output is correct
4 Correct 388 ms 10800 KB Output is correct
5 Correct 376 ms 10620 KB Output is correct
6 Correct 381 ms 10696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3164 KB Output is correct
2 Correct 2 ms 3216 KB Output is correct
3 Correct 2 ms 3164 KB Output is correct
4 Correct 2 ms 3164 KB Output is correct
5 Correct 2 ms 3164 KB Output is correct
6 Correct 2 ms 3164 KB Output is correct
7 Correct 2 ms 3416 KB Output is correct
8 Correct 8 ms 3164 KB Output is correct
9 Correct 9 ms 3156 KB Output is correct
10 Correct 10 ms 3164 KB Output is correct
11 Correct 8 ms 3160 KB Output is correct
12 Correct 9 ms 3164 KB Output is correct
13 Correct 9 ms 3164 KB Output is correct
14 Correct 8 ms 3260 KB Output is correct
15 Correct 8 ms 3220 KB Output is correct
16 Correct 8 ms 3164 KB Output is correct
17 Correct 10 ms 3260 KB Output is correct
18 Correct 388 ms 10800 KB Output is correct
19 Correct 376 ms 10620 KB Output is correct
20 Correct 381 ms 10696 KB Output is correct
21 Correct 395 ms 10684 KB Output is correct
22 Correct 396 ms 9656 KB Output is correct
23 Correct 422 ms 11528 KB Output is correct
24 Correct 389 ms 11520 KB Output is correct
25 Correct 407 ms 11188 KB Output is correct
26 Correct 397 ms 10968 KB Output is correct
27 Correct 398 ms 8856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3164 KB Output is correct
2 Correct 9 ms 3156 KB Output is correct
3 Correct 10 ms 3164 KB Output is correct
4 Correct 9 ms 3164 KB Output is correct
5 Correct 9 ms 3160 KB Output is correct
6 Correct 9 ms 3164 KB Output is correct
7 Correct 388 ms 10800 KB Output is correct
8 Correct 376 ms 10620 KB Output is correct
9 Correct 381 ms 10696 KB Output is correct
10 Correct 120 ms 11464 KB Output is correct
11 Correct 115 ms 11528 KB Output is correct
12 Correct 113 ms 12416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3164 KB Output is correct
2 Correct 2 ms 3216 KB Output is correct
3 Correct 2 ms 3164 KB Output is correct
4 Correct 2 ms 3164 KB Output is correct
5 Correct 2 ms 3164 KB Output is correct
6 Correct 2 ms 3164 KB Output is correct
7 Correct 2 ms 3416 KB Output is correct
8 Correct 2 ms 3164 KB Output is correct
9 Correct 4 ms 3164 KB Output is correct
10 Correct 2 ms 3160 KB Output is correct
11 Correct 2 ms 3160 KB Output is correct
12 Correct 2 ms 3164 KB Output is correct
13 Correct 2 ms 3164 KB Output is correct
14 Correct 2 ms 3164 KB Output is correct
15 Correct 8 ms 3164 KB Output is correct
16 Correct 9 ms 3156 KB Output is correct
17 Correct 10 ms 3164 KB Output is correct
18 Correct 8 ms 3160 KB Output is correct
19 Correct 9 ms 3164 KB Output is correct
20 Correct 9 ms 3164 KB Output is correct
21 Correct 8 ms 3260 KB Output is correct
22 Correct 8 ms 3220 KB Output is correct
23 Correct 8 ms 3164 KB Output is correct
24 Correct 10 ms 3260 KB Output is correct
25 Correct 9 ms 3164 KB Output is correct
26 Correct 9 ms 3160 KB Output is correct
27 Correct 9 ms 3164 KB Output is correct
28 Correct 9 ms 3164 KB Output is correct
29 Correct 9 ms 3220 KB Output is correct
30 Correct 9 ms 3164 KB Output is correct
31 Correct 10 ms 3164 KB Output is correct
32 Correct 9 ms 3224 KB Output is correct
33 Correct 9 ms 3160 KB Output is correct
34 Correct 9 ms 3164 KB Output is correct
35 Correct 388 ms 10800 KB Output is correct
36 Correct 376 ms 10620 KB Output is correct
37 Correct 381 ms 10696 KB Output is correct
38 Correct 395 ms 10684 KB Output is correct
39 Correct 396 ms 9656 KB Output is correct
40 Correct 422 ms 11528 KB Output is correct
41 Correct 389 ms 11520 KB Output is correct
42 Correct 407 ms 11188 KB Output is correct
43 Correct 397 ms 10968 KB Output is correct
44 Correct 398 ms 8856 KB Output is correct
45 Correct 120 ms 11464 KB Output is correct
46 Correct 115 ms 11528 KB Output is correct
47 Correct 113 ms 12416 KB Output is correct
48 Correct 135 ms 11068 KB Output is correct
49 Correct 120 ms 10956 KB Output is correct
50 Correct 120 ms 10956 KB Output is correct
51 Correct 114 ms 11472 KB Output is correct
52 Correct 117 ms 11212 KB Output is correct
53 Correct 121 ms 10952 KB Output is correct
54 Correct 117 ms 11588 KB Output is correct