Submission #615567

# Submission time Handle Problem Language Result Execution time Memory
615567 2022-07-31T10:42:30 Z nohaxjustsoflo Crocodile's Underground City (IOI11_crocodile) C++17
100 / 100
477 ms 95404 KB
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> order_set;
mt19937 mt_rand(chrono::high_resolution_clock::now().time_since_epoch().count());
//uniform_int_distribution<int> gen; ///(min, max)
//int random() {return gen(mt_rand);}
const int mxN=1e6+5;
const int mod=998244353;
const int mxlogN=40;
const int mxK=26;
const int inf=2e9;
const int K=600;
struct edge
{
    int u,v,w;
    int other(int i)
    {
        return i^u^v;
    }
}es[mxN];
vector<int> adj[mxN];
int vis[mxN];
//#include "crocodile.h"

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    for(int i=0; i<M; i++)
    {
        int u=R[i][0],v=R[i][1],w=L[i];
        es[i]={u,v,w};
        adj[u].push_back(i);
        adj[v].push_back(i);
    }
    priority_queue<pair<ll,int>> q;
    for(int i=0; i<K; i++)
    {
        q.push({0,P[i]});
        vis[P[i]]=1;
    }
    while(q.size())
    {
        auto par=q.top(); q.pop();
        int i=par.second;
        ll w=-par.first;
        if(vis[i]!=1)
        {
            vis[i]++;
            continue;
        }
        vis[i]++;
        if(!i) return w;
        for(int e:adj[i])
        {
            int j=es[e].other(i);
            if(vis[j]>=2) continue;
            ll d=w+es[e].w;
            q.push({-d,j});
        }
    }
    return -1;
}
/*
int main()
{
    int n,m,k; cin >> n >> m >> k;
    int r[m][2], l[m], p[n];
    for(int i=0; i<m; i++) cin >> r[i][0] >> r[i][1] >> l[i];
    for(int i=0; i<k; i++) cin >> p[i];
    cout << travel_plan(n,m,r,l,k,p) << "\n";
}
*/
/*
5 4 3
0 1 2
0 2 3
3 2 1
2 4 4
1 3 4
*/
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 12 ms 23764 KB Output is correct
3 Correct 12 ms 23864 KB Output is correct
4 Correct 15 ms 23844 KB Output is correct
5 Correct 14 ms 23892 KB Output is correct
6 Correct 15 ms 23880 KB Output is correct
7 Correct 13 ms 23844 KB Output is correct
8 Correct 14 ms 23852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 12 ms 23764 KB Output is correct
3 Correct 12 ms 23864 KB Output is correct
4 Correct 15 ms 23844 KB Output is correct
5 Correct 14 ms 23892 KB Output is correct
6 Correct 15 ms 23880 KB Output is correct
7 Correct 13 ms 23844 KB Output is correct
8 Correct 14 ms 23852 KB Output is correct
9 Correct 14 ms 24140 KB Output is correct
10 Correct 15 ms 23840 KB Output is correct
11 Correct 15 ms 23876 KB Output is correct
12 Correct 18 ms 24532 KB Output is correct
13 Correct 14 ms 24532 KB Output is correct
14 Correct 13 ms 23764 KB Output is correct
15 Correct 15 ms 23892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 12 ms 23764 KB Output is correct
3 Correct 12 ms 23864 KB Output is correct
4 Correct 15 ms 23844 KB Output is correct
5 Correct 14 ms 23892 KB Output is correct
6 Correct 15 ms 23880 KB Output is correct
7 Correct 13 ms 23844 KB Output is correct
8 Correct 14 ms 23852 KB Output is correct
9 Correct 14 ms 24140 KB Output is correct
10 Correct 15 ms 23840 KB Output is correct
11 Correct 15 ms 23876 KB Output is correct
12 Correct 18 ms 24532 KB Output is correct
13 Correct 14 ms 24532 KB Output is correct
14 Correct 13 ms 23764 KB Output is correct
15 Correct 15 ms 23892 KB Output is correct
16 Correct 477 ms 76996 KB Output is correct
17 Correct 77 ms 35292 KB Output is correct
18 Correct 89 ms 36404 KB Output is correct
19 Correct 473 ms 95404 KB Output is correct
20 Correct 377 ms 88284 KB Output is correct
21 Correct 78 ms 28748 KB Output is correct
22 Correct 403 ms 69092 KB Output is correct