Submission #394585

# Submission time Handle Problem Language Result Execution time Memory
394585 2021-04-27T01:43:04 Z definitelynotmee Crocodile's Underground City (IOI11_crocodile) C++
100 / 100
914 ms 89808 KB
#include <bits/stdc++.h>
#include "crocodile.h"
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INFL = (1LL<<62)-1;
const int INF = (1<<30)-1;
const int MAXN = 100001;

vector<pll> grafo[MAXN];

int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]){
    
    for(int i = 0; i < m; i++){
        grafo[r[i][0]].push_back({r[i][1], l[i]});
        grafo[r[i][1]].push_back({r[i][0], l[i]});
    }
    
    multiset<pll> s;
    vector<pll> dist(n,{INFL,INFL});
    vector<set<ll>> possd (n);
    vector<bool> passq(n,0);
    for(int i = 0; i < k; i++)
        s.insert({0,p[i]}), dist[p[i]] = {0,0};
    
    while(!s.empty()){
        ll cur = s.begin()->second;
        s.erase(s.begin());
        if(passq[cur] == 1)
            continue;
        passq[cur] = 1;
        for(int i = 0; i < grafo[cur].size(); i++){
            
            ll viz = grafo[cur][i].ff;
            ll vizp = grafo[cur][i].ss;
            if(vizp + dist[cur].ff < dist[viz].ss){
                dist[viz].ff = dist[viz].ss;
                dist[viz].ss = vizp + dist[cur].ff;
                s.insert({dist[viz].ff, viz});
            } else if(vizp + dist[cur].ff < dist[viz].ff){
                dist[viz].ff = vizp + dist[cur].ff;
                s.insert({dist[viz].ff, viz});
            }
        }
    }
    return dist[0].ff;
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:37:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         for(int i = 0; i < grafo[cur].size(); i++){
      |                        ~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2656 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 3 ms 2764 KB Output is correct
5 Correct 3 ms 2764 KB Output is correct
6 Correct 2 ms 2764 KB Output is correct
7 Correct 3 ms 2800 KB Output is correct
8 Correct 3 ms 2764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2656 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 3 ms 2764 KB Output is correct
5 Correct 3 ms 2764 KB Output is correct
6 Correct 2 ms 2764 KB Output is correct
7 Correct 3 ms 2800 KB Output is correct
8 Correct 3 ms 2764 KB Output is correct
9 Correct 5 ms 3048 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 3 ms 2768 KB Output is correct
12 Correct 5 ms 3276 KB Output is correct
13 Correct 5 ms 3424 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 3 ms 2764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2656 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 3 ms 2764 KB Output is correct
5 Correct 3 ms 2764 KB Output is correct
6 Correct 2 ms 2764 KB Output is correct
7 Correct 3 ms 2800 KB Output is correct
8 Correct 3 ms 2764 KB Output is correct
9 Correct 5 ms 3048 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 3 ms 2768 KB Output is correct
12 Correct 5 ms 3276 KB Output is correct
13 Correct 5 ms 3424 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 3 ms 2764 KB Output is correct
16 Correct 641 ms 75244 KB Output is correct
17 Correct 130 ms 27076 KB Output is correct
18 Correct 175 ms 28636 KB Output is correct
19 Correct 914 ms 89808 KB Output is correct
20 Correct 367 ms 58496 KB Output is correct
21 Correct 54 ms 13036 KB Output is correct
22 Correct 383 ms 56756 KB Output is correct