Submission #977528

# Submission time Handle Problem Language Result Execution time Memory
977528 2024-05-08T06:17:40 Z vjudge1 Cats or Dogs (JOI18_catdog) C++17
38 / 100
3000 ms 7884 KB
#include "catdog.h"
#include<bits/stdc++.h>
using namespace std;
vector<int> v;
vector<int>adj[100100];
int state[100100],dp[100100][2];
void dfs(int n,int p){
    dp[n][0]=dp[n][1]=0;
    for(auto i:adj[n])  if(i-p) dfs(i,n),
        dp[n][0]+=min(dp[i][0],dp[i][1]+1),
        dp[n][1]+=min(dp[i][0]+1,dp[i][1]);
    if(state[n])
        dp[n][2-state[n]]=1e9;
}
void initialize(int N, std::vector<int> A, std::vector<int> B) {
    for(int i=0;i<N-1;i++)
        adj[A[i]].push_back(B[i]),
        adj[B[i]].push_back(A[i]);
}
int cat(int v) {
    state[v]=1;
    dfs(1,0);
    return min(dp[1][0],dp[1][1]);
}

int dog(int v) {
    state[v]=2;
    dfs(1,0);
    return min(dp[1][0],dp[1][1]);
}

int neighbor(int v) {
    state[v]=0;
    dfs(1,0);
    return min(dp[1][0],dp[1][1]);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3932 KB Output is correct
2 Correct 1 ms 3672 KB Output is correct
3 Correct 1 ms 3788 KB Output is correct
4 Correct 1 ms 3676 KB Output is correct
5 Correct 2 ms 3792 KB Output is correct
6 Correct 1 ms 3676 KB Output is correct
7 Correct 1 ms 3676 KB Output is correct
8 Correct 1 ms 3676 KB Output is correct
9 Correct 1 ms 3676 KB Output is correct
10 Correct 1 ms 3676 KB Output is correct
11 Correct 1 ms 3676 KB Output is correct
12 Correct 1 ms 3676 KB Output is correct
13 Correct 1 ms 3676 KB Output is correct
14 Correct 1 ms 3676 KB Output is correct
15 Correct 1 ms 3676 KB Output is correct
16 Correct 1 ms 3676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3932 KB Output is correct
2 Correct 1 ms 3672 KB Output is correct
3 Correct 1 ms 3788 KB Output is correct
4 Correct 1 ms 3676 KB Output is correct
5 Correct 2 ms 3792 KB Output is correct
6 Correct 1 ms 3676 KB Output is correct
7 Correct 1 ms 3676 KB Output is correct
8 Correct 1 ms 3676 KB Output is correct
9 Correct 1 ms 3676 KB Output is correct
10 Correct 1 ms 3676 KB Output is correct
11 Correct 1 ms 3676 KB Output is correct
12 Correct 1 ms 3676 KB Output is correct
13 Correct 1 ms 3676 KB Output is correct
14 Correct 1 ms 3676 KB Output is correct
15 Correct 1 ms 3676 KB Output is correct
16 Correct 1 ms 3676 KB Output is correct
17 Correct 6 ms 3676 KB Output is correct
18 Correct 10 ms 3932 KB Output is correct
19 Correct 4 ms 3676 KB Output is correct
20 Correct 1 ms 3676 KB Output is correct
21 Correct 2 ms 3676 KB Output is correct
22 Correct 3 ms 3676 KB Output is correct
23 Correct 10 ms 3676 KB Output is correct
24 Correct 7 ms 3676 KB Output is correct
25 Correct 4 ms 3672 KB Output is correct
26 Correct 2 ms 3676 KB Output is correct
27 Correct 2 ms 3676 KB Output is correct
28 Correct 3 ms 3676 KB Output is correct
29 Correct 10 ms 3900 KB Output is correct
30 Correct 3 ms 3676 KB Output is correct
31 Correct 2 ms 3676 KB Output is correct
32 Correct 3 ms 3676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3932 KB Output is correct
2 Correct 1 ms 3672 KB Output is correct
3 Correct 1 ms 3788 KB Output is correct
4 Correct 1 ms 3676 KB Output is correct
5 Correct 2 ms 3792 KB Output is correct
6 Correct 1 ms 3676 KB Output is correct
7 Correct 1 ms 3676 KB Output is correct
8 Correct 1 ms 3676 KB Output is correct
9 Correct 1 ms 3676 KB Output is correct
10 Correct 1 ms 3676 KB Output is correct
11 Correct 1 ms 3676 KB Output is correct
12 Correct 1 ms 3676 KB Output is correct
13 Correct 1 ms 3676 KB Output is correct
14 Correct 1 ms 3676 KB Output is correct
15 Correct 1 ms 3676 KB Output is correct
16 Correct 1 ms 3676 KB Output is correct
17 Correct 6 ms 3676 KB Output is correct
18 Correct 10 ms 3932 KB Output is correct
19 Correct 4 ms 3676 KB Output is correct
20 Correct 1 ms 3676 KB Output is correct
21 Correct 2 ms 3676 KB Output is correct
22 Correct 3 ms 3676 KB Output is correct
23 Correct 10 ms 3676 KB Output is correct
24 Correct 7 ms 3676 KB Output is correct
25 Correct 4 ms 3672 KB Output is correct
26 Correct 2 ms 3676 KB Output is correct
27 Correct 2 ms 3676 KB Output is correct
28 Correct 3 ms 3676 KB Output is correct
29 Correct 10 ms 3900 KB Output is correct
30 Correct 3 ms 3676 KB Output is correct
31 Correct 2 ms 3676 KB Output is correct
32 Correct 3 ms 3676 KB Output is correct
33 Execution timed out 3033 ms 7884 KB Time limit exceeded
34 Halted 0 ms 0 KB -