UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#214252#2763. 幻想乡的拜访tonysun0530Compile Error//C++1.4kb2024-11-16 20:29:122024-11-16 23:12:38

answer

#include <bits/stdc++.h>

#define x first
#define y second
#define PII pair<int, int>
#define int long long

using namespace std;

const int N = 1e6 + 10;
const int M = N << 1;
const int mod = 1e9 + 7;

int n;
int h[N], e[M], ne[M], w[N], idx;
int dist[N];
bool st[N];

void add(int a, int b)
{
    e[idx] = b, ne[idx] = h[a], h[a] = idx ++ ;
}

void dijkstra(int s)
{
    memset(dist, 0x3f, sizeof dist);
    dist[s] = 0;
    priority_queue<PII, vector<PII>, greater<PII>> heap;
    heap.push({0, s});

    while (heap.size())
    {
        pair<int, int> t = heap.top();
        heap.pop();

        int ver = t.second, distance = t.first;

        if (st[ver]) continue;
        st[ver] = true;

        for (int i = h[ver]; i != -1; i = ne[i])
        {
            int j = e[i];
            if (dist[j] > dist[ver] + 1)
            {
                dist[j] = dist[ver] + 1;
                heap.push({dist[j], j});
            }
        }
    }
}

signed main()
{
    memset(h, -1, sizeof h);
    cin >> n;
    for(int i = 1 ; i < n ; i ++ )
    {
        int a, b;
        cin >> a >> b;
        add(a, b);
        add(b, a);
    }
    int ans = 0;
    for(int i = 1 ; i <= n ; i ++ )
    {
        memset(st, 0, sizeof st);
        dijkstra(i);
        for(int j = 1 ; j < i ; j ++ ) ans = (ans + dist[j] * i % mod * j % mod) % mod;
    }
    cout << ans;
    return 0;
}

Details

answer.code: In function 'void dijkstra(long long int)':
answer.code:28:49: error: '>>' should be '> >' within a nested template argument list
     priority_queue<PII, vector<PII>, greater<PII>> heap;\x0d
                                                 ^
answer.code:29:14: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 [enabled by default]
     heap.push({0, s});\x0d
              ^
answer.code:29:21: warning: extended initializer lists only available with -std=c++...