Submission #497255

# Submission time Handle Problem Language Result Execution time Memory
497255 2021-12-22T21:21:57 Z FerThugGato12500 Crocodile's Underground City (IOI11_crocodile) C++17
100 / 100
454 ms 59180 KB
#include<bits/stdc++.h>
using namespace std;
#include "crocodile.h"
const int lmt = 100005;

struct wer{
    int i;
    long long x;
};

bool operator < (const wer &a, const wer &b){
    return a.x > b.x;
}

bool mark[lmt];
bool vis[lmt];
vector< pair<int, int> > ed[lmt];
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    for(int i = 0; i <M; i++){
        ed[R[i][0]].push_back({R[i][1],L[i]});
        ed[R[i][1]].push_back({R[i][0],L[i]});
    }
    priority_queue<wer> mqun;
    for(int i = 0; i < K; i++){
        mqun.push({P[i],0});
        mark[P[i]] = true;
    }
    while(mqun.size()){
        int ind = mqun.top().i;
        long long v = mqun.top().x; mqun.pop();
 //       cout<<ind<<" "<<v<<" : ";
        if(mark[ind]){
        //    cout<<"a\n";
            if(ind==0){
                return (int)(v);
            }
            if(!vis[ind]){
                vis[ind] = true;
                for(int i = 0; i < ed[ind].size(); i++){
                    int to = ed[ind][i].first;
                    long long vs = v+ed[ind][i].second;
                    if(!vis[to]){
                        mqun.push({to,vs});
                    }
                }
            }
        }else {
            mark[ind] = true;
   //         cout<<"b\n";
        }
    }
}


Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:40:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |                 for(int i = 0; i < ed[ind].size(); i++){
      |                                ~~^~~~~~~~~~~~~~~~
crocodile.cpp:24:25: warning: control reaches end of non-void function [-Wreturn-type]
   24 |     priority_queue<wer> mqun;
      |                         ^~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2648 KB Output is correct
2 Correct 1 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2636 KB Output is correct
5 Correct 2 ms 2636 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 2 ms 2636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2648 KB Output is correct
2 Correct 1 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2636 KB Output is correct
5 Correct 2 ms 2636 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 2 ms 2636 KB Output is correct
9 Correct 3 ms 3020 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 2 ms 2764 KB Output is correct
12 Correct 5 ms 3532 KB Output is correct
13 Correct 4 ms 3532 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 2 ms 2764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2648 KB Output is correct
2 Correct 1 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2636 KB Output is correct
5 Correct 2 ms 2636 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 2 ms 2636 KB Output is correct
9 Correct 3 ms 3020 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 2 ms 2764 KB Output is correct
12 Correct 5 ms 3532 KB Output is correct
13 Correct 4 ms 3532 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 2 ms 2764 KB Output is correct
16 Correct 411 ms 56812 KB Output is correct
17 Correct 83 ms 10500 KB Output is correct
18 Correct 74 ms 11892 KB Output is correct
19 Correct 454 ms 59180 KB Output is correct
20 Correct 248 ms 53776 KB Output is correct
21 Correct 35 ms 6728 KB Output is correct
22 Correct 337 ms 32708 KB Output is correct