Submission #337017

# Submission time Handle Problem Language Result Execution time Memory
337017 2020-12-17T21:48:51 Z r_v_n Crocodile's Underground City (IOI11_crocodile) C++14
Compilation error
0 ms 0 KB
using namespace std;
#include <bits/stdc++.h>
#define ll long long
int dp[100001];
int n;
int m, k;
vector<pair<int, int>> adj[100001];
map<int, int> is;
ll int n, m;
vector<pair<ll int, ll int>> adj[100011];
vector<ll int> dist(100001 + 1, 1e18);
void simple_dijkstra()
{
    priority_queue<pair<ll int, ll int>, vector<pair<ll int, ll int>>, greater<pair<ll int, ll int>>> q;
    q.push({0ll, 1ll});
    dist[1] = 0ll;
    while (!q.empty())
    {
        ll int currnode = q.top().second;
        ll int currdis = q.top().first;
        q.pop();
        if (dist[currnode] < currdis)
            continue;
        for (auto it : adj[currnode])
        {
            if (currdis + it.second < dist[it.first])
            {
                dist[it.first] = currdis + it.second;
                q.push({dist[it.first], it.first});
            }
        }
    }
}
void dfs(int v, int p = -1)
{
    if (adj[v].size() == 1)
    {
        if (is[v])
            dp[v] = 0;
        else
            dp[v] = 1e9;
        return;
    }
    vector<int> store;
    for (auto it : adj[v])
    {
        if (it.first == p)
            continue;
        dfs(it.first, v);
        store.push_back(dp[it.first] + it.second);
    }
    sort(store.begin(), store.end());
    dp[v] = store[1];
}
// void solve()
// {
//     cin >> n >> m >> k;
//     for (int i = 0; i <= n; i++)
//     {
//         adj[i].clear();
//         dp[i] = 0;
//     }
//     is.clear();
//     for (int i = 0; i < m; i++)
//     {
//         int a, b, c;
//         cin >> a >> b >> c;
//         adj[a].push_back({b, c});
//         adj[b].push_back({a, c});
//     }
//     for (int i = 0; i < k; i++)
//     {
//         int a;
//         cin >> a;
//         is[a] = 1;
//     }
//     dfs(0);
//     cout << dp[0] << endl;
// }
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    for (int i = 0; i < M; i++)
    {
        adj[R[i][0]].push_back(make_pair(R[i][1], L[i]));
        adj[R[i][1]].push_back(make_pair(R[i][0], L[i]));
    }
    map<int, int> f;
    vector<int> d(n + 1,1e9);
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
    for (int i = 0; i < K; i++)
    {
        is[P[i]] = 1;
        q.push({0, P[i]});
    }
    dfs(0);
    while (!q.empty())
    {
        int dt = q.top().first;
        int node = q.top().second;
        if (!is[node])
        {
            is[node] = 1;
            continue;
        }
        if (is[node] == 2)
            continue;
        if (is[node] == 1)
            is[node] = 2;
        for (auto it : adj[node])
        {
            if (!is[it.first])
            {
                is[it.first] = 1;
            }
            if (is[it.first] == 2)
                continue;
            if (is[it.first] == 1)
            {
                d[it.first] = min(d[it.first], d[node] + it.second);
                q.push({d[it.first], it.first});
            }
        }
    }
    return d[0];
}

Compilation message

crocodile.cpp:9:8: error: conflicting declaration 'long long int n'
    9 | ll int n, m;
      |        ^
crocodile.cpp:5:5: note: previous declaration as 'int n'
    5 | int n;
      |     ^
crocodile.cpp:9:11: error: conflicting declaration 'long long int m'
    9 | ll int n, m;
      |           ^
crocodile.cpp:6:5: note: previous declaration as 'int m'
    6 | int m, k;
      |     ^
crocodile.cpp:10:30: error: conflicting declaration 'std::vector<std::pair<long long int, long long int> > adj [100011]'
   10 | vector<pair<ll int, ll int>> adj[100011];
      |                              ^~~
crocodile.cpp:7:24: note: previous declaration as 'std::vector<std::pair<int, int> > adj [100001]'
    7 | vector<pair<int, int>> adj[100001];
      |                        ^~~
crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:98:13: warning: unused variable 'dt' [-Wunused-variable]
   98 |         int dt = q.top().first;
      |             ^~