Submission #394590

# Submission time Handle Problem Language Result Execution time Memory
394590 2021-04-27T02:33:02 Z definitelynotmee Crocodile's Underground City (IOI11_crocodile) C++
100 / 100
1800 ms 116044 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<ll> dist(n,INFL);
    vector<multiset<ll>> possd (n);
    vector<bool> passq(n,0);
    for(int i = 0; i < n; i++)
        s.insert({INFL,i});
    for(int i = 0; i < k; i++)
        s.erase({INFL,p[i]}),s.insert({0,p[i]}), dist[p[i]] = 0;
    
    while(!s.empty()){
        ll cur = s.begin()->second;
        s.erase(s.begin());
        passq[cur] = 1;
        if(dist[cur] >= INFL)
            break;
        for(int i = 0; i < grafo[cur].size(); i++){
            
            ll viz = grafo[cur][i].ff;
            ll vizp = grafo[cur][i].ss;
            if(!passq[viz]){
                possd[viz].insert((ll)vizp + dist[cur]);
                if(possd[viz].size()>1 && dist[viz] > *(++possd[viz].begin())){
                    s.erase({dist[viz],viz});
                    dist[viz] = *(++possd[viz].begin());
                    s.insert({dist[viz],viz});
                }
            }
        }
    }
    return dist[0];
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:38: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]
   38 |         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 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 3 ms 2764 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 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 3 ms 2764 KB Output is correct
7 Correct 3 ms 2764 KB Output is correct
8 Correct 3 ms 2764 KB Output is correct
9 Correct 5 ms 3148 KB Output is correct
10 Correct 3 ms 2636 KB Output is correct
11 Correct 3 ms 2892 KB Output is correct
12 Correct 9 ms 3660 KB Output is correct
13 Correct 8 ms 3788 KB Output is correct
14 Correct 3 ms 2636 KB Output is correct
15 Correct 3 ms 2892 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 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 3 ms 2764 KB Output is correct
7 Correct 3 ms 2764 KB Output is correct
8 Correct 3 ms 2764 KB Output is correct
9 Correct 5 ms 3148 KB Output is correct
10 Correct 3 ms 2636 KB Output is correct
11 Correct 3 ms 2892 KB Output is correct
12 Correct 9 ms 3660 KB Output is correct
13 Correct 8 ms 3788 KB Output is correct
14 Correct 3 ms 2636 KB Output is correct
15 Correct 3 ms 2892 KB Output is correct
16 Correct 1540 ms 108612 KB Output is correct
17 Correct 176 ms 27752 KB Output is correct
18 Correct 234 ms 30272 KB Output is correct
19 Correct 1800 ms 116044 KB Output is correct
20 Correct 477 ms 101684 KB Output is correct
21 Correct 79 ms 13724 KB Output is correct
22 Correct 565 ms 93584 KB Output is correct