ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#213643 | #2715. 8.4t4 | wanghanyu393 | Compile Error | / | / | C++ | 1.1kb | 2024-11-12 22:28:49 | 2024-11-13 08:30:18 |
answer
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
const int mod=1e9+7;
const int maxn=5005;
bool vis[maxn];
vector<int> e[maxn];
int n;
inline void view_all(vector<int> &cur,int x,int fa)
{
cur.push_back(x);
for(int p: e[x])
{
if (vis[p]) continue;
if (p == fa) continue;
view_all(cur, p, x);
}
}
inline int calc(int x)
{
vector<int> cur;
int ans = 0;
view_all(cur, x, -1);
for(auto w : cur)
{
int res = 1;
vis[w] = 1;
for(auto p: e[w])
{
if (vis[p]) continue;
res = 1ll * res * calc(p) % mod;
}
vis[w] = 0;
ans = (ans + res) % mod;
}
return ans;
}
inline int get_ans()
{
return calc(1);
}
void solve(){
int n;
cin >> n;
for(int i = 1; i < n; i++){
int u, v;
cin >> u >> v;
e[u].push_back(v);
e[v].push_back(u);
}
cout << get_ans();
}
int main(){
int t = 1;
//cin >> t;
while(t--){
solve();
}
return 0;
}
详细
answer.code: In function 'void view_all(std::vector<int>&, int, int)': answer.code:15:16: error: range-based 'for' loops are not allowed in C++98 mode for(int p: e[x])\x0d ^ answer.code: In function 'int calc(int)': answer.code:27:14: error: 'w' does not name a type for(auto w : cur)\x0d ^ answer.code:39:5: error: expected ';' before 'return' return ans;\x0d ^ answer.code:39:5: error: expected primary-expression before 'return' answer.code:39:5: error: ex...