Submission #255410

# Submission time Handle Problem Language Result Execution time Memory
255410 2020-07-31T21:46:19 Z hhh07 Crocodile's Underground City (IOI11_crocodile) C++14
Compilation error
0 ms 0 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <set>
#include <cmath>
#include <climits>
#include <cstring>
#include "crocodile.h"
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;

vector<vector<ii>> adjList(100007, vector<ii>());
const int INF = 1e9 + 7;
int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]){
    for (ll i = 0; i < m; i++){
        adjList[r[i][0]].push_back(make_pair(r[i][1], l[i]));
        adjList[r[i][1]].push_back(make_pair(r[i][0], l[i]));
    }
    
    vector<ii> t(n, {INF, INF});
    priority_queue<ii, vector<ii>, greater<ii>> pq;
    for (ll i = 0; i < k; i++){
        t[p[i]] = {0, 0};
        pq.push({0, p[i]});
    }
    
    while(!pq.empty()){
        auto curr = pq.top();
        pq.pop();
        if (t[curr.second].first != curr.first)
            continue;
        for (ll i = 0; i < adjList[curr.second].size(); i++){
            ll d = adjList[curr.second][i].second, idx = adjList[curr.second][i].first;
            ll val = curr.first + d;
            if (t[idx].first > val){
                int prev = t[idx].first;
                t[idx].first = val;
                if (t[idx].second > t[idx].first)
                    swap(t[idx].first, t[idx].second);
                
                if (t[idx].first != prev)
                    pq.push({t[idx].first, idx};)
            }
            
            
        }
    }
    
    
    return t[0].first;
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:38:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (ll i = 0; i < adjList[curr.second].size(); i++){
                        ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
crocodile.cpp:48:48: error: expected ')' before ';' token
                     pq.push({t[idx].first, idx};)
                                                ^
crocodile.cpp:47:17: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
                 if (t[idx].first != prev)
                 ^~
crocodile.cpp:48:49: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
                     pq.push({t[idx].first, idx};)
                                                 ^
crocodile.cpp:48:49: error: expected primary-expression before ')' token