답안 #205346

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
205346 2020-02-28T15:42:35 Z mode149256 악어의 지하 도시 (IOI11_crocodile) C++14
89 / 100
855 ms 73708 KB
/*input

*/
#include <bits/stdc++.h>
#include "crocodile.h"
using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef vector<pi> vpi;
typedef vector<vpi> vpii;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<pd> vpd;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef std::string str;
typedef std::vector<str> vs;

#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"

const int MOD = 1000000007;
const ll INF = std::numeric_limits<ll>::max();
const int MX = 100101;
const ld PI = 3.14159265358979323846264338327950288419716939937510582097494L;

template<typename T>
pair<T, T> operator+(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x + b.x, a.y + b.y); }
template<typename T>
pair<T, T> operator-(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x - b.x, a.y - b.y); }
template<typename T>
T operator*(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.x + a.y * b.y); }
template<typename T>
T operator^(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.y - a.y * b.x); }

template<typename T>
void print(vector<T> vec, string name = "") {
	cout << name;
	for (auto u : vec)
		cout << u << ' ';
	cout << '\n';
}

const ll DID = (ll)1e17;

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
	vector<vpl> edges(N);
	{
		for (int i = 0; i < M; ++i)
		{
			int a = R[i][0];
			int b = R[i][1];
			edges[a].emplace_back(b, L[i]);
			edges[b].emplace_back(a, L[i]);
		}
	}

	vll dis(N, vl(2, DID));
	priority_queue<pl, vpl, greater<pl>> pq;

	for (int i = 0; i < K; ++i)
	{
		int c = P[i];
		dis[c][0] = dis[c][1] = 0;
		pq.push({0, c});
	}

	while (pq.size()) {
		pl dab = pq.top(); pq.pop();

		int c = (int)dab.y;
		ll d = dab.x;
		if (d > dis[c][1]) continue;

		for (auto u : edges[c]) {
			ll newDis = d + u.y;
			if (newDis < dis[u.x][0]) {
				dis[u.x][1] = dis[u.x][0];
				dis[u.x][0] = newDis;

				if (dis[u.x][1] != DID)
					pq.push({dis[u.x][1], u.x});
			} else if (newDis < dis[u.x][1]) {
				dis[u.x][1] = newDis;
				pq.push({dis[u.x][1], u.x});
			}
		}
	}

	return (int)dis[0][1];
}


/* Look for:
* special cases (n=1?)
* overflow (ll vs int?)
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* array bounds
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 6 ms 504 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 6 ms 504 KB Output is correct
8 Correct 5 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 6 ms 504 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 6 ms 504 KB Output is correct
8 Correct 5 ms 504 KB Output is correct
9 Correct 7 ms 632 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 6 ms 504 KB Output is correct
12 Correct 9 ms 888 KB Output is correct
13 Correct 8 ms 1016 KB Output is correct
14 Correct 6 ms 504 KB Output is correct
15 Correct 5 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 6 ms 504 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 6 ms 504 KB Output is correct
8 Correct 5 ms 504 KB Output is correct
9 Correct 7 ms 632 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 6 ms 504 KB Output is correct
12 Correct 9 ms 888 KB Output is correct
13 Correct 8 ms 1016 KB Output is correct
14 Correct 6 ms 504 KB Output is correct
15 Correct 5 ms 504 KB Output is correct
16 Correct 626 ms 65516 KB Output is correct
17 Correct 105 ms 18296 KB Output is correct
18 Correct 153 ms 19852 KB Output is correct
19 Correct 855 ms 73708 KB Output is correct
20 Correct 366 ms 52728 KB Output is correct
21 Correct 52 ms 7928 KB Output is correct
22 Incorrect 387 ms 49400 KB Output isn't correct