Submission #254369

# Submission time Handle Problem Language Result Execution time Memory
254369 2020-07-29T22:01:38 Z ChrisT Crocodile's Underground City (IOI11_crocodile) C++17
100 / 100
751 ms 64872 KB
#include<bits/stdc++.h>
#include "crocodile.h"
using namespace std;
const int MN = 1e5 + 5;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
vector<pii> adj[MN];
ll dist[MN][2];
int wot[MN][2];
int travel_plan (int n, int m, int r[][2], int l[], int k, int e[]) {
	for (int i = 0; i < m; i++) {
		adj[++r[i][0]].emplace_back(++r[i][1],l[i]);
		adj[r[i][1]].emplace_back(r[i][0],l[i]);
	}
	memset(dist,0x3f,sizeof dist);
	priority_queue<pli,vector<pli>,greater<pli>> pq;
	for (int i = 0; i < k; i++) {
		++e[i];
		dist[e[i]][0] = dist[e[i]][1] = 0;
		pq.push({0,e[i]});
	}
	while (!pq.empty()) {
		ll d = pq.top().first; int cur = pq.top().second; pq.pop();
		if (d > dist[cur][1]) continue;
		for (pii p : adj[cur]) {
			ll nd = d + p.second, old = dist[p.first][1];
			if (nd < dist[p.first][0]) {
				if (wot[p.first][0] != cur) {
					dist[p.first][1] = dist[p.first][0];
					wot[p.first][1] = wot[p.first][0];
				} 
				wot[p.first][0] = cur;
				dist[p.first][0] = nd;
			} else if (wot[p.first][0] != cur && nd < dist[p.first][1]) {
				wot[p.first][1] = cur;
				dist[p.first][1] = nd;
			}
			if (old != dist[p.first][1]) {
				pq.push({dist[p.first][1],p.first});
			}
		}
	}
	return dist[1][1];
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4224 KB Output is correct
2 Correct 2 ms 4224 KB Output is correct
3 Correct 2 ms 4224 KB Output is correct
4 Correct 3 ms 4352 KB Output is correct
5 Correct 5 ms 4352 KB Output is correct
6 Correct 3 ms 4352 KB Output is correct
7 Correct 4 ms 4352 KB Output is correct
8 Correct 3 ms 4352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4224 KB Output is correct
2 Correct 2 ms 4224 KB Output is correct
3 Correct 2 ms 4224 KB Output is correct
4 Correct 3 ms 4352 KB Output is correct
5 Correct 5 ms 4352 KB Output is correct
6 Correct 3 ms 4352 KB Output is correct
7 Correct 4 ms 4352 KB Output is correct
8 Correct 3 ms 4352 KB Output is correct
9 Correct 5 ms 4480 KB Output is correct
10 Correct 4 ms 4224 KB Output is correct
11 Correct 5 ms 4352 KB Output is correct
12 Correct 6 ms 4736 KB Output is correct
13 Correct 6 ms 4736 KB Output is correct
14 Correct 3 ms 4224 KB Output is correct
15 Correct 4 ms 4352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4224 KB Output is correct
2 Correct 2 ms 4224 KB Output is correct
3 Correct 2 ms 4224 KB Output is correct
4 Correct 3 ms 4352 KB Output is correct
5 Correct 5 ms 4352 KB Output is correct
6 Correct 3 ms 4352 KB Output is correct
7 Correct 4 ms 4352 KB Output is correct
8 Correct 3 ms 4352 KB Output is correct
9 Correct 5 ms 4480 KB Output is correct
10 Correct 4 ms 4224 KB Output is correct
11 Correct 5 ms 4352 KB Output is correct
12 Correct 6 ms 4736 KB Output is correct
13 Correct 6 ms 4736 KB Output is correct
14 Correct 3 ms 4224 KB Output is correct
15 Correct 4 ms 4352 KB Output is correct
16 Correct 558 ms 59816 KB Output is correct
17 Correct 91 ms 15352 KB Output is correct
18 Correct 113 ms 16888 KB Output is correct
19 Correct 751 ms 64872 KB Output is correct
20 Correct 343 ms 51192 KB Output is correct
21 Correct 43 ms 9336 KB Output is correct
22 Correct 360 ms 47736 KB Output is correct