Submission #255406

# Submission time Handle Problem Language Result Execution time Memory
255406 2020-07-31T21:36:33 Z hhh07 Crocodile's Underground City (IOI11_crocodile) C++14
89 / 100
726 ms 93284 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 (val <= t[idx].second){
                t[idx].first = t[idx].second;
                t[idx].second = val;
                pq.push({t[idx].first, idx});
            }
            else if (val < t[idx].first){
                t[idx].first = val;
                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++){
                        ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 2 ms 2816 KB Output is correct
4 Correct 2 ms 2816 KB Output is correct
5 Correct 2 ms 2816 KB Output is correct
6 Correct 2 ms 2816 KB Output is correct
7 Correct 2 ms 2816 KB Output is correct
8 Correct 2 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 2 ms 2816 KB Output is correct
4 Correct 2 ms 2816 KB Output is correct
5 Correct 2 ms 2816 KB Output is correct
6 Correct 2 ms 2816 KB Output is correct
7 Correct 2 ms 2816 KB Output is correct
8 Correct 2 ms 2816 KB Output is correct
9 Correct 4 ms 3072 KB Output is correct
10 Correct 2 ms 2688 KB Output is correct
11 Correct 3 ms 2816 KB Output is correct
12 Correct 8 ms 3456 KB Output is correct
13 Correct 5 ms 3456 KB Output is correct
14 Correct 2 ms 2688 KB Output is correct
15 Correct 3 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 2 ms 2816 KB Output is correct
4 Correct 2 ms 2816 KB Output is correct
5 Correct 2 ms 2816 KB Output is correct
6 Correct 2 ms 2816 KB Output is correct
7 Correct 2 ms 2816 KB Output is correct
8 Correct 2 ms 2816 KB Output is correct
9 Correct 4 ms 3072 KB Output is correct
10 Correct 2 ms 2688 KB Output is correct
11 Correct 3 ms 2816 KB Output is correct
12 Correct 8 ms 3456 KB Output is correct
13 Correct 5 ms 3456 KB Output is correct
14 Correct 2 ms 2688 KB Output is correct
15 Correct 3 ms 2816 KB Output is correct
16 Correct 573 ms 84840 KB Output is correct
17 Correct 114 ms 19820 KB Output is correct
18 Correct 146 ms 22260 KB Output is correct
19 Correct 726 ms 93284 KB Output is correct
20 Correct 344 ms 67504 KB Output is correct
21 Correct 53 ms 10488 KB Output is correct
22 Incorrect 402 ms 64628 KB Output isn't correct