# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
703071 | Markomafko972 | Crocodile's Underground City (IOI11_crocodile) | C++14 | 821 ms | 63588 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "crocodile.h"
#define X first
#define Y second
#define pb push_back
#define pii pair<int, int>
typedef long long ll;
using namespace std;
const int MOD = 1e9 + 7;
const ll INF = 1e18;
const int OFF = (1 << 20);
//int N, M, K;
//int niz[1000005][2];
//int putd[1000005];
//int cham[100005];
vector<pii> v[100005];
pair<ll, ll> dist[100005];
set< pair<ll, int> > s;
int travel_plan(int n, int m, int e[][2], int l[], int k, int ex[]) {
for (int i = 0; i < m; i++) {
v[e[i][0]].push_back({e[i][1], l[i]});
v[e[i][1]].push_back({e[i][0], l[i]});
}
for (int i = 0; i < n; i++) {
dist[i] = {INF, INF};
s.insert({INF, i});
}
for (int i = 0; i < k; i++) {
s.erase({INF, ex[i]});
s.insert({0, ex[i]});
dist[ex[i]] = {0, 0};
}
while (!s.empty()) {
ll cost = (s.begin() -> first);
int cvor = (s.begin() -> second);
s.erase(s.begin());
for (int i = 0; i < v[cvor].size(); i++) {
ll novi = cost+v[cvor][i].Y;
int sus = v[cvor][i].X;
if (novi < dist[sus].X) {
s.erase({dist[sus].Y, sus});
dist[sus].Y = dist[sus].X;
dist[sus].X = novi;
s.insert({dist[sus].Y, sus});
}
else if (novi < dist[sus].Y) {
s.erase({dist[sus].Y, sus});
dist[sus].Y = novi;
s.insert({dist[sus].Y, sus});
}
}
}
return dist[0].Y;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |