Submission #1295940

#TimeUsernameProblemLanguageResultExecution timeMemory
1295940hssaan_arifCrocodile's Underground City (IOI11_crocodile)C++20
Compilation error
0 ms0 KiB
#include "crocodile.h"
// #include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<queue>
#include<map>
using namespace std;

#define endl "\n"
#define pb push_back
// #define int long long
#define ll long long
#define fi first
#define se second

const int N = 1e5 + 5, M = 1e9 + 7, LG = 20;

// ll n , A[N] ,m ,k, u , v , l , R[N][2] , L[N] , P[N];
vector<ll> lis[N];


int travel_plan(int n, int m, int R[][2], int L[], int k, int P[])
{
    int fin = 0;
    ll vi[n] = {} , Dis[N] = {};
    map<pair<ll,ll> , ll> mp , cn;
    for (int i=0 ; i<n ; i++){
        Dis[i] = 1e18;
    }

    auto stt = std::chrono::system_clock::now();
    for (int i=0 ; i<m ; i++){
        int u = R[i][0] , v = R[i][1];
        lis[u].pb(v);
        lis[v].pb(u);
        mp[{u,v}] = mp[{v,u}] = L[i];
        auto nw = std::chrono::system_clock::now();

        std::chrono::duration<double> tm = nw - stt;
        if (tm >= 1.9)
            cout<<1 / 0;
    }
    priority_queue<pair<ll,ll> , vector<pair<ll,ll>> , greater<pair<ll,ll>>> pq;
    for (int i=0 ; i<k ; i++){
        Dis[P[i]] = 0;
        pq.push({0 , P[i]});
        // cn[P[i]] = 2;
        vi[P[i]] = 1;
    }
    
    while(pq.size() && Dis[0] == 1e18){
        int v = pq.top().se , sr = pq.top().fi ; pq.pop();
        // fin++;
        
        if (vi[v] != 1){
            vi[v]++;
            continue;
        }else{
            Dis[v] = sr;
            vi[v]++;
            for (int u : lis[v]){
                if (cn[{Dis[v] + mp[{v,u}] , u}]>=2 || vi[u]>=2 || Dis[u]!=1e18) continue;
                cn[{Dis[v] + mp[{v,u}] , u}]++;
                pq.push({Dis[v] + mp[{v,u}] , u});
            }
            
        }
    }
    // cout << Dis[0] << endl;
    return Dis[0];
}

// int main(){
//     cin >> n >> m >> k;
//     for (int i=0 ; i<m ; i++){
//         cin >> u >> v >> l;
//         R[i][0] = u;
//         R[i][1] = v;
//         L[i] = l;
//     }
//     for (int i=0 ; i<k ; i++){
//         cin >> l;
//         P[i] = l;
//     }

//     cout << travel_plan(n , m , R , L , k , P);
// }

Compilation message (stderr)

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:31:21: error: 'std::chrono' has not been declared
   31 |     auto stt = std::chrono::system_clock::now();
      |                     ^~~~~~
crocodile.cpp:37:24: error: 'std::chrono' has not been declared
   37 |         auto nw = std::chrono::system_clock::now();
      |                        ^~~~~~
crocodile.cpp:39:14: error: 'std::chrono' has not been declared
   39 |         std::chrono::duration<double> tm = nw - stt;
      |              ^~~~~~
crocodile.cpp:39:31: error: expected primary-expression before 'double'
   39 |         std::chrono::duration<double> tm = nw - stt;
      |                               ^~~~~~
crocodile.cpp:40:16: error: expected unqualified-id before '>=' token
   40 |         if (tm >= 1.9)
      |                ^~
crocodile.cpp:41:21: warning: division by zero [-Wdiv-by-zero]
   41 |             cout<<1 / 0;
      |                   ~~^~~