# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
955662 | vjudge1 | Power Plant (JOI20_power) | C++17 | 3 ms | 9564 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int n;
int x,y;
vector<int>a[300000];
int ktr[300000];
int f[300000];
string s;
int asw=0;
void sol(int i){
ktr[i]=1;
int o=0;
int mx=0;
for(int u:a[i]){
if(!ktr[u]){
sol(u);
f[i]+=f[u];
}
}
if(s[i]=='1'){
f[i]++;
asw++;
if(f[i]>2){
f[i]=2;
asw--;
}
}
}
int main(){
cin >>n;
for(int i=1;i<n;i++){
cin >>x>>y;
a[x].push_back(y);
a[y].push_back(x);
}
cin >>s;
s=" "+s;
sol(1);
cout<<asw;
}
/*
5 4
2 1 3
1 3 5 6
1 1 2 4
2 2 3
*/
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |