UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#213575#2715. 8.4t4stawalrCompile Error//C++983b2024-11-12 21:08:182024-11-12 23:45:19

answer

#include<bits/stdc++.h>
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);
}
int main()
{
    int x,y;
    scanf("%d",&n);
    for(int i=1;i<n;i++)
    {
        scanf("%d%d",&x,&y);
        e[x].push_back(y);
        e[y].push_back(x);
    }
    printf("%d",get_ans());
}

详细

answer.code: In function 'void view_all(std::vector<int>&, int, int)':
answer.code:11: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:23:14: error: 'w' does not name a type
     for(auto w : cur)\x0d
              ^
answer.code:35:5: error: expected ';' before 'return'
     return ans;\x0d
     ^
answer.code:35:5: error: expected primary-expression before 'return'
answer.code:35:5: error: ex...