Submission #667625

#TimeUsernameProblemLanguageResultExecution timeMemory
667625berrStar Trek (CEOI20_startrek)C++17
0 / 100
3 ms5076 KiB
#include <bits/stdc++.h> using namespace std; const int N=1e5+37; vector<int> adj[N], adj2[N]; int huh, huuh, mod=1e9+7; int mul(int x, int y){ return (x*y)%mod; } int poww(int x, int y) { if(y==0) return 1; int tmp=poww(x, y/2); if(y%2) return mul(tmp, mul(tmp, x)); return mul(tmp, tmp); } int dfs2(int v, int p, int d) { int f=1; if(d%2==0) f=0; int count=0, val=0; for(auto i: adj2[v]) { if(i==p) continue; if(dfs2(i, v, d+1)) { if(d%2==0){ f=1; } } else { if(d%2) f=0; } } return f; } int dfs(int v, int p, int d) { int f=1; if(d%2==0) f=0; int count=0, val=0; for(auto i: adj[v]) { if(i==p) continue; if(dfs(i, v, d+1)) { if(d%2==0){ f=1; } } else { if(d%2) f=0; } } if(huh==v) { if(dfs2(huuh, 0, d+1)) { if(d%2==0) f=1; } else { if(d%2) f=0; } } return f; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, d; cin>>n>>d; for(int i=0; i<n-1; i++){ int x, y; cin>>x>>y; adj[x].push_back(y); adj[y].push_back(x); adj2[x].push_back(y); adj2[y].push_back(x); } int ans=0; { cout<<poww(2, d+1); } }

Compilation message (stderr)

startrek.cpp: In function 'int dfs2(int, int, int)':
startrek.cpp:25:9: warning: unused variable 'count' [-Wunused-variable]
   25 |     int count=0, val=0;
      |         ^~~~~
startrek.cpp:25:18: warning: unused variable 'val' [-Wunused-variable]
   25 |     int count=0, val=0;
      |                  ^~~
startrek.cpp: In function 'int dfs(int, int, int)':
startrek.cpp:57:9: warning: unused variable 'count' [-Wunused-variable]
   57 |     int count=0, val=0;
      |         ^~~~~
startrek.cpp:57:18: warning: unused variable 'val' [-Wunused-variable]
   57 |     int count=0, val=0;
      |                  ^~~
startrek.cpp: In function 'int main()':
startrek.cpp:110:9: warning: unused variable 'ans' [-Wunused-variable]
  110 |     int ans=0;
      |         ^~~
#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...