Submission #1003220

# Submission time Handle Problem Language Result Execution time Memory
1003220 2024-06-20T07:56:25 Z vjudge1 Crocodile's Underground City (IOI11_crocodile) C++17
100 / 100
256 ms 55320 KB
#include "crocodile.h"
#include <bits/stdc++.h>
#define OPT         ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define intt        long long
#define ll          long long
#define pb          push_back
#define ff          first
#define arr         array
#define vll         vector<int>
#define rep(i,j,k)  for(int i = j; i <= k; ++i)
#define all(a)      a.begin(),a.end()
#define pii         pair<int,int>
#define endll       '\n'
using namespace std;
const int INF = 1e9;
const int N = 1e5 + 5;




int travel_plan(int n, int m, int r[][2], int L[], int k, int p[])
{
    vector<vector<arr<int,2>>>g(N);
    for(int i = 0; i < m; i ++){
        g[r[i][0]].push_back({r[i][1], L[i]});
        g[r[i][1]].push_back({r[i][0], L[i]});
    }
    arr<int,2>dist[n];
    bool vis[n];
    for(int i = 0; i < n; ++i)
        dist[i] = {INF,INF}, vis[i] = false;
    priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>>q;
    for(int i = 0; i < k; ++i)
    {
        q.push({0, p[i]});
        dist[p[i]] = {0 , 0};
    }
    while(!q.empty())
    {
        int v = q.top().second;
        q.pop();
        if(vis[v])
            continue;
        vis[v] = true;
        for(auto i : g[v])
        {
            int u = i[0];
            int w = i[1];
            if(dist[u][0] > dist[v][1] + w)
            {
                dist[u][1] = dist[u][0];
				dist[u][0] = dist[v][1] + w ;
				q.push({dist[u][1], u});
            }
            else if(dist[u][1] > dist[v][1] + w)
            {
                dist[u][1] = dist[v][1] + w;
				q.push({dist[u][1], u});
            }
        }
    }
    return dist[0][1];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2908 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2908 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 2 ms 2908 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2908 KB Output is correct
12 Correct 2 ms 3164 KB Output is correct
13 Correct 2 ms 3164 KB Output is correct
14 Correct 1 ms 2648 KB Output is correct
15 Correct 2 ms 2904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2908 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 2 ms 2908 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2908 KB Output is correct
12 Correct 2 ms 3164 KB Output is correct
13 Correct 2 ms 3164 KB Output is correct
14 Correct 1 ms 2648 KB Output is correct
15 Correct 2 ms 2904 KB Output is correct
16 Correct 212 ms 50308 KB Output is correct
17 Correct 51 ms 13488 KB Output is correct
18 Correct 66 ms 15036 KB Output is correct
19 Correct 256 ms 55320 KB Output is correct
20 Correct 150 ms 43344 KB Output is correct
21 Correct 28 ms 7940 KB Output is correct
22 Correct 179 ms 39636 KB Output is correct