Submission #1520792
Source Code Expand
#include<iostream> #include<iomanip> #include<math.h> #include<vector> #include<algorithm> #include<set> #include<map> #include<queue> #include<stack> #include<string> #include<complex> #include<unordered_map> #define INF 1000000000ll #define MOD 1000000007ll #define EPS 1e-8 #define REP(i, m) for(long long i = 0; i < m; ++i) #define FOR(i, n, m) for(long long i = n; i < m; ++i) #define ALL(v) v.begin(), v.end() #define pb push_back using namespace std; typedef long long ll; typedef pair<ll, ll> P; typedef long double ld; vector<vector<int> > adj; ll dfs(int pos, int c, int b) { ll res=1; REP(i,adj[pos].size()) { if(adj[pos][i]!=b) { if(c==0) res*=dfs(adj[pos][i],0,pos)+dfs(adj[pos][i],1,pos); else res*=dfs(adj[pos][i],0,pos); } } return res % MOD; } int main() { int n; cin>>n; adj.resize(n); REP(i,n-1) { int a,b; cin>>a>>b; --a; --b; adj[a].pb(b); adj[b].pb(a); } cout<<dfs(0,0,-1)+dfs(0,1,-1)<<endl; }
Submission Info
Submission Time | |
---|---|
Task | D - 塗り絵 |
User | gazelle |
Language | Bash (GNU bash v4.3.11) |
Score | 0 |
Code Size | 1006 Byte |
Status | RE |
Exec Time | 4 ms |
Memory | 592 KB |
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 0 / 100 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
000.txt | RE | 4 ms | 584 KB |
001.txt | RE | 3 ms | 580 KB |
002.txt | RE | 3 ms | 580 KB |
003.txt | RE | 3 ms | 580 KB |
004.txt | RE | 4 ms | 572 KB |
005.txt | RE | 3 ms | 588 KB |
006.txt | RE | 3 ms | 584 KB |
007.txt | RE | 3 ms | 576 KB |
008.txt | RE | 4 ms | 580 KB |
009.txt | RE | 3 ms | 580 KB |
010.txt | RE | 3 ms | 592 KB |
011.txt | RE | 3 ms | 580 KB |
012.txt | RE | 3 ms | 580 KB |
013.txt | RE | 3 ms | 584 KB |
014.txt | RE | 3 ms | 584 KB |
015.txt | RE | 3 ms | 580 KB |
016.txt | RE | 3 ms | 584 KB |
017.txt | RE | 3 ms | 576 KB |
018.txt | RE | 3 ms | 584 KB |
019.txt | RE | 3 ms | 588 KB |
020.txt | RE | 4 ms | 588 KB |
021.txt | RE | 3 ms | 580 KB |