답안 #1000778

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1000778 2024-06-18T08:36:59 Z imarn 9월 (APIO24_september) C++17
100 / 100
276 ms 10736 KB
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define plx pair<ll,int>
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
using namespace std;
const int mxn=1e5+5;
vector<int>g[mxn];
bool vis[mxn]{0};
int cnt[6]{0};
void dfs(int u){
    vis[u]=1;
    for(int i=0;i<5;i++)cnt[i]++;
    for(auto v:g[u]){
        if(!vis[v])dfs(v);
    }
}
int solve(int N, int M, std::vector<int> F, std::vector<std::vector<int>> S){
    for(int i=1;i<N;i++)g[F[i]].pb(i);
    int ans=0;
    for(int i=0;i<N-1;i++){
        for(int j=0;j<M;j++){
            if(!vis[S[j][i]])dfs(S[j][i]);
            if(vis[S[j][i]])cnt[j]--;
        }bool ch=0;
        for(int j=0;j<M;j++)if(cnt[j]!=0)ch=1;
        if(!ch)ans++;
    }memset(vis,0,sizeof vis);memset(cnt,0,sizeof cnt);
    for(int i=0;i<mxn;i++)g[i].clear();
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 2 ms 2652 KB Output is correct
3 Correct 2 ms 2652 KB Output is correct
4 Correct 2 ms 2908 KB Output is correct
5 Correct 1 ms 2908 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 2 ms 2652 KB Output is correct
3 Correct 2 ms 2652 KB Output is correct
4 Correct 2 ms 2908 KB Output is correct
5 Correct 1 ms 2908 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2836 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 2 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2908 KB Output is correct
13 Correct 2 ms 2648 KB Output is correct
14 Correct 1 ms 2648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2904 KB Output is correct
2 Correct 6 ms 2908 KB Output is correct
3 Correct 9 ms 2912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 2 ms 2652 KB Output is correct
3 Correct 2 ms 2652 KB Output is correct
4 Correct 2 ms 2908 KB Output is correct
5 Correct 1 ms 2908 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2836 KB Output is correct
8 Correct 8 ms 2904 KB Output is correct
9 Correct 6 ms 2908 KB Output is correct
10 Correct 9 ms 2912 KB Output is correct
11 Correct 5 ms 2908 KB Output is correct
12 Correct 5 ms 2908 KB Output is correct
13 Correct 8 ms 2908 KB Output is correct
14 Correct 6 ms 2908 KB Output is correct
15 Correct 5 ms 2908 KB Output is correct
16 Correct 5 ms 2944 KB Output is correct
17 Correct 5 ms 2904 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2904 KB Output is correct
2 Correct 6 ms 2908 KB Output is correct
3 Correct 9 ms 2912 KB Output is correct
4 Correct 8 ms 2904 KB Output is correct
5 Correct 5 ms 2908 KB Output is correct
6 Correct 5 ms 2908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 2 ms 2652 KB Output is correct
3 Correct 2 ms 2652 KB Output is correct
4 Correct 2 ms 2908 KB Output is correct
5 Correct 1 ms 2908 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2836 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 2 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2908 KB Output is correct
13 Correct 2 ms 2648 KB Output is correct
14 Correct 1 ms 2648 KB Output is correct
15 Correct 8 ms 2904 KB Output is correct
16 Correct 6 ms 2908 KB Output is correct
17 Correct 9 ms 2912 KB Output is correct
18 Correct 5 ms 2908 KB Output is correct
19 Correct 5 ms 2908 KB Output is correct
20 Correct 8 ms 2908 KB Output is correct
21 Correct 6 ms 2908 KB Output is correct
22 Correct 5 ms 2908 KB Output is correct
23 Correct 5 ms 2944 KB Output is correct
24 Correct 5 ms 2904 KB Output is correct
25 Correct 8 ms 2904 KB Output is correct
26 Correct 5 ms 2908 KB Output is correct
27 Correct 5 ms 2908 KB Output is correct
28 Correct 5 ms 2908 KB Output is correct
29 Correct 6 ms 2908 KB Output is correct
30 Correct 5 ms 2908 KB Output is correct
31 Correct 5 ms 2984 KB Output is correct
32 Correct 5 ms 2908 KB Output is correct
33 Correct 5 ms 2920 KB Output is correct
34 Correct 5 ms 2908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2904 KB Output is correct
2 Correct 6 ms 2908 KB Output is correct
3 Correct 9 ms 2912 KB Output is correct
4 Correct 236 ms 7572 KB Output is correct
5 Correct 276 ms 7568 KB Output is correct
6 Correct 274 ms 7568 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 2 ms 2652 KB Output is correct
3 Correct 2 ms 2652 KB Output is correct
4 Correct 2 ms 2908 KB Output is correct
5 Correct 1 ms 2908 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2836 KB Output is correct
8 Correct 8 ms 2904 KB Output is correct
9 Correct 6 ms 2908 KB Output is correct
10 Correct 9 ms 2912 KB Output is correct
11 Correct 5 ms 2908 KB Output is correct
12 Correct 5 ms 2908 KB Output is correct
13 Correct 8 ms 2908 KB Output is correct
14 Correct 6 ms 2908 KB Output is correct
15 Correct 5 ms 2908 KB Output is correct
16 Correct 5 ms 2944 KB Output is correct
17 Correct 5 ms 2904 KB Output is correct
18 Correct 236 ms 7572 KB Output is correct
19 Correct 276 ms 7568 KB Output is correct
20 Correct 274 ms 7568 KB Output is correct
21 Correct 260 ms 7084 KB Output is correct
22 Correct 251 ms 7096 KB Output is correct
23 Correct 256 ms 7600 KB Output is correct
24 Correct 244 ms 7592 KB Output is correct
25 Correct 243 ms 7084 KB Output is correct
26 Correct 260 ms 7084 KB Output is correct
27 Correct 250 ms 7592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2904 KB Output is correct
2 Correct 6 ms 2908 KB Output is correct
3 Correct 9 ms 2912 KB Output is correct
4 Correct 8 ms 2904 KB Output is correct
5 Correct 5 ms 2908 KB Output is correct
6 Correct 5 ms 2908 KB Output is correct
7 Correct 236 ms 7572 KB Output is correct
8 Correct 276 ms 7568 KB Output is correct
9 Correct 274 ms 7568 KB Output is correct
10 Correct 80 ms 10696 KB Output is correct
11 Correct 89 ms 10516 KB Output is correct
12 Correct 86 ms 10736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 2 ms 2652 KB Output is correct
3 Correct 2 ms 2652 KB Output is correct
4 Correct 2 ms 2908 KB Output is correct
5 Correct 1 ms 2908 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2836 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 2 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2908 KB Output is correct
13 Correct 2 ms 2648 KB Output is correct
14 Correct 1 ms 2648 KB Output is correct
15 Correct 8 ms 2904 KB Output is correct
16 Correct 6 ms 2908 KB Output is correct
17 Correct 9 ms 2912 KB Output is correct
18 Correct 5 ms 2908 KB Output is correct
19 Correct 5 ms 2908 KB Output is correct
20 Correct 8 ms 2908 KB Output is correct
21 Correct 6 ms 2908 KB Output is correct
22 Correct 5 ms 2908 KB Output is correct
23 Correct 5 ms 2944 KB Output is correct
24 Correct 5 ms 2904 KB Output is correct
25 Correct 8 ms 2904 KB Output is correct
26 Correct 5 ms 2908 KB Output is correct
27 Correct 5 ms 2908 KB Output is correct
28 Correct 5 ms 2908 KB Output is correct
29 Correct 6 ms 2908 KB Output is correct
30 Correct 5 ms 2908 KB Output is correct
31 Correct 5 ms 2984 KB Output is correct
32 Correct 5 ms 2908 KB Output is correct
33 Correct 5 ms 2920 KB Output is correct
34 Correct 5 ms 2908 KB Output is correct
35 Correct 236 ms 7572 KB Output is correct
36 Correct 276 ms 7568 KB Output is correct
37 Correct 274 ms 7568 KB Output is correct
38 Correct 260 ms 7084 KB Output is correct
39 Correct 251 ms 7096 KB Output is correct
40 Correct 256 ms 7600 KB Output is correct
41 Correct 244 ms 7592 KB Output is correct
42 Correct 243 ms 7084 KB Output is correct
43 Correct 260 ms 7084 KB Output is correct
44 Correct 250 ms 7592 KB Output is correct
45 Correct 80 ms 10696 KB Output is correct
46 Correct 89 ms 10516 KB Output is correct
47 Correct 86 ms 10736 KB Output is correct
48 Correct 86 ms 9164 KB Output is correct
49 Correct 84 ms 9160 KB Output is correct
50 Correct 83 ms 9428 KB Output is correct
51 Correct 84 ms 9420 KB Output is correct
52 Correct 84 ms 9160 KB Output is correct
53 Correct 83 ms 9160 KB Output is correct
54 Correct 83 ms 9672 KB Output is correct