답안 #570000

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
570000 2022-05-28T12:28:33 Z OttoTheDino Power Plant (JOI20_power) C++17
6 / 100
4 ms 5076 KB
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,s,e)                  for (int i = s; i <= e; ++i)
#define pb                          push_back
typedef vector<int> vi;
 
const int mx=2e5;
vi adj[mx+1];
int ans = 0;
string s;
 
int dfs (int u, int p) {
    int x = 0, c = 0;
    for (int v : adj[u]) {
        if (v==p) continue;
        int res = dfs (v, u);
        if (res) {
            c++;
            x += res;
        }
    }
    if (s[u-1]=='1') {
        if (c<2) ans = max(ans, x+1);
        x = max(x-1, 1);
    }
    ans = max(ans, x);
    return x;
}
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
 
    int n;cin>>n;
    rep(i,1,n-1){
       int u,v; cin>>u>>v;
       adj[u].pb(v);
       adj[v].pb(u);
    }
    cin >> s;
    dfs (1,0);
    cout << ans << "\n";
    
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4980 KB Output is correct
3 Correct 3 ms 4968 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 2 ms 4948 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Correct 3 ms 5024 KB Output is correct
10 Correct 3 ms 5020 KB Output is correct
11 Correct 3 ms 4948 KB Output is correct
12 Correct 3 ms 5016 KB Output is correct
13 Correct 3 ms 4948 KB Output is correct
14 Correct 4 ms 4948 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 4 ms 4948 KB Output is correct
17 Correct 3 ms 5020 KB Output is correct
18 Correct 3 ms 5012 KB Output is correct
19 Correct 3 ms 5020 KB Output is correct
20 Correct 3 ms 4948 KB Output is correct
21 Correct 3 ms 4948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4980 KB Output is correct
3 Correct 3 ms 4968 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 2 ms 4948 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Correct 3 ms 5024 KB Output is correct
10 Correct 3 ms 5020 KB Output is correct
11 Correct 3 ms 4948 KB Output is correct
12 Correct 3 ms 5016 KB Output is correct
13 Correct 3 ms 4948 KB Output is correct
14 Correct 4 ms 4948 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 4 ms 4948 KB Output is correct
17 Correct 3 ms 5020 KB Output is correct
18 Correct 3 ms 5012 KB Output is correct
19 Correct 3 ms 5020 KB Output is correct
20 Correct 3 ms 4948 KB Output is correct
21 Correct 3 ms 4948 KB Output is correct
22 Incorrect 4 ms 5076 KB Output isn't correct
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4980 KB Output is correct
3 Correct 3 ms 4968 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 2 ms 4948 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Correct 3 ms 5024 KB Output is correct
10 Correct 3 ms 5020 KB Output is correct
11 Correct 3 ms 4948 KB Output is correct
12 Correct 3 ms 5016 KB Output is correct
13 Correct 3 ms 4948 KB Output is correct
14 Correct 4 ms 4948 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 4 ms 4948 KB Output is correct
17 Correct 3 ms 5020 KB Output is correct
18 Correct 3 ms 5012 KB Output is correct
19 Correct 3 ms 5020 KB Output is correct
20 Correct 3 ms 4948 KB Output is correct
21 Correct 3 ms 4948 KB Output is correct
22 Incorrect 4 ms 5076 KB Output isn't correct
23 Halted 0 ms 0 KB -