Submission #666102

# Submission time Handle Problem Language Result Execution time Memory
666102 2022-11-27T15:35:21 Z chanhchuong123 Crocodile's Underground City (IOI11_crocodile) C++14
0 / 100
6 ms 5332 KB
#include <bits/stdc++.h>
#include "crocodile.h"
using namespace std;
#define task "C"
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

template <typename T1, typename T2> bool mini(T1 &a, T2 b) {
  if (a > b) {a = b; return true;} return false;
}
template <typename T1, typename T2> bool maxi(T1 &a, T2 b) {
  if (a < b) {a = b; return true;} return false;
}

const int MAXN = 1e5 + 4;
const int INF = 1e9 + 1;
int n, m, k;
int Exit[MAXN];
bool isExit[MAXN];
vector<pair<int, int>> adj[MAXN];


int d[MAXN][2];

struct node {
    int du, u;
    bool operator< (const node &other) const {
        return du > other.du;
    }
};
priority_queue<node> pq;

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];
        adj[u].push_back(make_pair(v, w));
        adj[v].push_back(make_pair(u, w));
    }
    for (int i = 0; i < n; i++) d[i][0] = d[i][1] = INF;
    for (int i = 0; i < k; i++) {
        d[p[i]][0] = 0;
        d[p[i]][1] = 0;
        pq.push({0, p[i]});
    }
    while (pq.size()) {
        int du = pq.top().du;
        int u = pq.top().u;
        pq.pop();
        if (d[u][1] != du) continue;

        for (pair<int, int> x: adj[u]) {
            int v = x.fi, w = x.se;
            if (d[v][0] >= du + w) {
                if (mini(d[v][1], d[v][0]))
                    pq.push({d[v][1], v});
                d[v][0] = du + w;
            } else if (d[v][1] > du + w) {
                d[v][1] = du + w;
                pq.push({d[v][1], v});
            }
        }
    }
    cout << d[0][1];
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:66:1: warning: no return statement in function returning non-void [-Wreturn-type]
   66 | }
      | ^
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 5332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 5332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 5332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -