답안 #72606

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
72606 2018-08-26T11:21:20 Z MrTEK 악어의 지하 도시 (IOI11_crocodile) C++14
100 / 100
857 ms 45208 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define len(a) (int)a.size()
#define fi first
#define sc second
#define d1(w) cerr<<#w<<":"<<w<<endl;
#define d2(w,c) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<endl;
#define d3(w,c,z) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<" "<<#z<<":"<<z<<endl;
#define left isc+isc
#define right isc+isc+1
#define mid (l+r)/2
#define FAfi_IO ios_base::sync_with_fidio(false);
#define escl '\n'
#define bit __builtin_popcount

typedef long long int ll;

const int maxn = 620;
const long long LINF = 1e18;
const int LOG = 31;
const int INF = 1e9;
const int N = 1e5 + 5;
const int M = 1e6 + 5;
const int SQ = 350;
const int MOD = 998244353;

typedef long long int lli;
typedef pair<int,int> pii;

struct node {
	int x,cost;
};

bool operator < (node a,node b) {
	return a.cost > b.cost;
}

priority_queue <node> Q;

vector <pii> ed[N];

int mn2[N],mn[N],ans[N];

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
	for (int i = 0 ; i < M ; i++) {
		ed[R[i][0]].pb(mp(R[i][1],L[i]));
		ed[R[i][1]].pb(mp(R[i][0],L[i]));
	}
	memset(mn,63,sizeof mn);
	memset(mn2,63,sizeof mn2);
	for (int i = 0 ; i < K ; i++) {
		if (P[i] == 0) return 0;
		Q.push({P[i],0});
		mn[P[i]] = mn2[P[i]] = 0;
	}
	while(len(Q)) {
		auto it = Q.top();
		Q.pop();
		if (it.cost > mn2[it.x]) continue;
		for (auto i : ed[it.x]) {
			int u = i.fi;
			int v = i.sc;
			int tut = mn2[u];
			mn2[u] = min(mn2[u],v + it.cost);
			if (mn2[u] < mn[u]) swap(mn2[u],mn[u]);
			if (mn2[u] != tut)
				Q.push({u,mn2[u]});
		}
	}
	return mn2[0];
}


# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 3448 KB Output is correct
2 Correct 5 ms 3556 KB Output is correct
3 Correct 5 ms 3556 KB Output is correct
4 Correct 7 ms 3640 KB Output is correct
5 Correct 6 ms 3660 KB Output is correct
6 Correct 5 ms 3660 KB Output is correct
7 Correct 5 ms 3672 KB Output is correct
8 Correct 5 ms 3792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 3448 KB Output is correct
2 Correct 5 ms 3556 KB Output is correct
3 Correct 5 ms 3556 KB Output is correct
4 Correct 7 ms 3640 KB Output is correct
5 Correct 6 ms 3660 KB Output is correct
6 Correct 5 ms 3660 KB Output is correct
7 Correct 5 ms 3672 KB Output is correct
8 Correct 5 ms 3792 KB Output is correct
9 Correct 7 ms 3864 KB Output is correct
10 Correct 5 ms 3864 KB Output is correct
11 Correct 5 ms 3864 KB Output is correct
12 Correct 9 ms 4032 KB Output is correct
13 Correct 8 ms 4160 KB Output is correct
14 Correct 7 ms 4160 KB Output is correct
15 Correct 6 ms 4160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 3448 KB Output is correct
2 Correct 5 ms 3556 KB Output is correct
3 Correct 5 ms 3556 KB Output is correct
4 Correct 7 ms 3640 KB Output is correct
5 Correct 6 ms 3660 KB Output is correct
6 Correct 5 ms 3660 KB Output is correct
7 Correct 5 ms 3672 KB Output is correct
8 Correct 5 ms 3792 KB Output is correct
9 Correct 7 ms 3864 KB Output is correct
10 Correct 5 ms 3864 KB Output is correct
11 Correct 5 ms 3864 KB Output is correct
12 Correct 9 ms 4032 KB Output is correct
13 Correct 8 ms 4160 KB Output is correct
14 Correct 7 ms 4160 KB Output is correct
15 Correct 6 ms 4160 KB Output is correct
16 Correct 717 ms 41732 KB Output is correct
17 Correct 100 ms 41732 KB Output is correct
18 Correct 134 ms 41732 KB Output is correct
19 Correct 857 ms 45208 KB Output is correct
20 Correct 443 ms 45208 KB Output is correct
21 Correct 50 ms 45208 KB Output is correct
22 Correct 404 ms 45208 KB Output is correct