제출 #963133

#제출 시각아이디문제언어결과실행 시간메모리
963133antonStar Trek (CEOI20_startrek)C++17
8 / 100
1091 ms576 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...