Submission #394591

# Submission time Handle Problem Language Result Execution time Memory
394591 2021-04-27T02:33:55 Z definitelynotmee Crocodile's Underground City (IOI11_crocodile) C++
100 / 100
1004 ms 81640 KB
#include <bits/stdc++.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]});
    }
    
    set<pll> s;
    vector<pll> dist(n,{INFL,INFL});
    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:35: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]
   35 |         for(int i = 0; i < grafo[cur].size(); i++){
      |                        ~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 3 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 2636 KB Output is correct
7 Correct 3 ms 2764 KB Output is correct
8 Correct 3 ms 2764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 3 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 2636 KB Output is correct
7 Correct 3 ms 2764 KB Output is correct
8 Correct 3 ms 2764 KB Output is correct
9 Correct 4 ms 3024 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 3 ms 2764 KB Output is correct
12 Correct 5 ms 3276 KB Output is correct
13 Correct 5 ms 3276 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 4 ms 2764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 3 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 2636 KB Output is correct
7 Correct 3 ms 2764 KB Output is correct
8 Correct 3 ms 2764 KB Output is correct
9 Correct 4 ms 3024 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 3 ms 2764 KB Output is correct
12 Correct 5 ms 3276 KB Output is correct
13 Correct 5 ms 3276 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 4 ms 2764 KB Output is correct
16 Correct 647 ms 69684 KB Output is correct
17 Correct 129 ms 20600 KB Output is correct
18 Correct 181 ms 22128 KB Output is correct
19 Correct 1004 ms 81640 KB Output is correct
20 Correct 324 ms 54956 KB Output is correct
21 Correct 57 ms 10188 KB Output is correct
22 Correct 360 ms 51704 KB Output is correct