이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAX_N = 1000;
const int mod = 1e9+7;
vector<int> adj[2*MAX_N];
bool can_win[2*MAX_N];
void find_win(int u,int p, int a){
for(auto v: adj[u]){
if( v!=a){
find_win( v, (p+1)%2, u);
}
}
if(p == 0){
can_win[u] = false;
for(auto v: adj[u]){
if( v!=a){
can_win[u] |= can_win[v];
}
}
}
else{
can_win[u] = true;
for(auto v: adj[u]){
if(v!=a){
can_win[u] &= can_win[v];
}
}
}
}
signed main(){
int n, d;
cin>>n>>d;
for(int i = 0; i<n-1;i++){
int a, b;
cin>>a>>b;
adj[a-1].push_back(b-1);
adj[b-1].push_back(a-1);
adj[a-1+n].push_back(n+b-1);
adj[b-1+n].push_back(n+a-1);
}
int res= 0;
for(int a = 0; a<n; a++){
for(int b= n; b<2*n; b++){
adj[a].push_back(b);
find_win(0, 0, -1);
if(can_win[0]){
res++;
}
adj[a].pop_back();
}
}
cout<<res<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |