#include<bits/stdc++.h>
#include"catdog.h"
using namespace std;
typedef int ll;
typedef vector<int> vll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
ll N;
vector<ll> g[1010];
ll dp[1010][2],col[1010];
void dfs(ll x,ll from){
rep(k,2)dp[x][k]=1e9;
if(col[x]!=1)dp[x][0]=0;
if(col[x]!=0)dp[x][1]=0;
for(auto y:g[x])if(y!=from){
dfs(y,x);
dp[x][0]+=min(dp[y][0],dp[y][1]+1);
dp[x][1]+=min(dp[y][0]+1,dp[y][1]);
}
}
ll solve(){
dfs(1,0);
return min(dp[1][0],dp[1][1]);
}
ll cat(int v){
col[v]=0;
return solve();
}
ll dog(int v){
col[v]=1;
return solve();
}
ll neighbor(int v){
col[v]=2;
return solve();
}
void initialize(ll n,vll a,vll b){
rep(i,n-1){
g[a[i]].push_back(b[i]);
g[b[i]].push_back(a[i]);
}
for(int i=1;i<=n;i++)col[i]=2;
}
/*int main(){
}*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
5 ms |
376 KB |
Output is correct |
15 |
Correct |
5 ms |
380 KB |
Output is correct |
16 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
5 ms |
376 KB |
Output is correct |
15 |
Correct |
5 ms |
380 KB |
Output is correct |
16 |
Correct |
5 ms |
376 KB |
Output is correct |
17 |
Correct |
14 ms |
376 KB |
Output is correct |
18 |
Correct |
18 ms |
504 KB |
Output is correct |
19 |
Correct |
11 ms |
376 KB |
Output is correct |
20 |
Correct |
5 ms |
376 KB |
Output is correct |
21 |
Correct |
6 ms |
376 KB |
Output is correct |
22 |
Correct |
7 ms |
376 KB |
Output is correct |
23 |
Correct |
21 ms |
376 KB |
Output is correct |
24 |
Correct |
16 ms |
376 KB |
Output is correct |
25 |
Correct |
9 ms |
376 KB |
Output is correct |
26 |
Correct |
7 ms |
376 KB |
Output is correct |
27 |
Correct |
6 ms |
376 KB |
Output is correct |
28 |
Correct |
7 ms |
376 KB |
Output is correct |
29 |
Correct |
18 ms |
504 KB |
Output is correct |
30 |
Correct |
7 ms |
376 KB |
Output is correct |
31 |
Correct |
6 ms |
376 KB |
Output is correct |
32 |
Correct |
8 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
5 ms |
376 KB |
Output is correct |
15 |
Correct |
5 ms |
380 KB |
Output is correct |
16 |
Correct |
5 ms |
376 KB |
Output is correct |
17 |
Correct |
14 ms |
376 KB |
Output is correct |
18 |
Correct |
18 ms |
504 KB |
Output is correct |
19 |
Correct |
11 ms |
376 KB |
Output is correct |
20 |
Correct |
5 ms |
376 KB |
Output is correct |
21 |
Correct |
6 ms |
376 KB |
Output is correct |
22 |
Correct |
7 ms |
376 KB |
Output is correct |
23 |
Correct |
21 ms |
376 KB |
Output is correct |
24 |
Correct |
16 ms |
376 KB |
Output is correct |
25 |
Correct |
9 ms |
376 KB |
Output is correct |
26 |
Correct |
7 ms |
376 KB |
Output is correct |
27 |
Correct |
6 ms |
376 KB |
Output is correct |
28 |
Correct |
7 ms |
376 KB |
Output is correct |
29 |
Correct |
18 ms |
504 KB |
Output is correct |
30 |
Correct |
7 ms |
376 KB |
Output is correct |
31 |
Correct |
6 ms |
376 KB |
Output is correct |
32 |
Correct |
8 ms |
376 KB |
Output is correct |
33 |
Runtime error |
47 ms |
4344 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
34 |
Halted |
0 ms |
0 KB |
- |