답안 #851273

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
851273 2023-09-19T09:24:15 Z Halym2007 악어의 지하 도시 (IOI11_crocodile) C++11
100 / 100
488 ms 64960 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define MAXM 100005
#define ff first
#define ss second

priority_queue <pair<int, int>, vector <pair<int, int>>, greater <pair<int, int>>> q;
vector <pair <int, int>> adj[MAXM];
int val[MAXM], dp[MAXM];

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
//	return 111;
	for (int i = 0; i < M; ++i) {
		int u = R[i][0], v = R[i][1], w = L[i];
		adj[u].pb ({v, w});
		adj[v].pb ({u, w});
	}
	for (int i = 0; i < K; ++i) {
		q.push({0, P[i]});
		val[P[i]] = 1;
	}
	while (!q.empty()) {
		int x = q.top().ff;
		int y = q.top().ss;
		q.pop();
		if (val[y] == 2) continue;
		val[y]++;
		if (val[y] == 1) continue;
		dp[y] = x;
		for (auto i : adj[y]) {
			int v = i.ff, w = i.ss;
			if (val[v] != 2) q.push({x + w, v});
		} 
	}
	return dp[0];
}

//
//
//#include <stdio.h>
//#include <stdlib.h>
//
//#define MAX_N 50000
//#define MAX_M 10000000
//
//static int N, M;
//static int R[MAX_M][2];
//static int L[MAX_M];
//static int K;
//static int P[MAX_N];
//
//void read_input()
//{
//  int i;
//  scanf("%d %d %d",&N,&M,&K);
//  for(i=0; i<M; i++)
//    scanf("%d %d %d",&R[i][0],&R[i][1],&L[i]);
//  for(i=0; i<K; i++)
//    scanf("%d",&P[i]);
//}
//
//int main() {
//	freopen ("input.txt", "r", stdin);
//  int ans;
//  read_input();
//  ans = travel_plan(N,M,R,L,K,P);
//  printf("%d\n", ans);
//  return 0;
//}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6488 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6488 KB Output is correct
6 Correct 2 ms 6488 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6488 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6488 KB Output is correct
6 Correct 2 ms 6488 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 3 ms 6748 KB Output is correct
10 Correct 1 ms 6488 KB Output is correct
11 Correct 2 ms 6612 KB Output is correct
12 Correct 5 ms 7004 KB Output is correct
13 Correct 5 ms 7000 KB Output is correct
14 Correct 1 ms 6624 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6488 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 2 ms 6492 KB Output is correct
5 Correct 2 ms 6488 KB Output is correct
6 Correct 2 ms 6488 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 3 ms 6748 KB Output is correct
10 Correct 1 ms 6488 KB Output is correct
11 Correct 2 ms 6612 KB Output is correct
12 Correct 5 ms 7004 KB Output is correct
13 Correct 5 ms 7000 KB Output is correct
14 Correct 1 ms 6624 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 425 ms 62736 KB Output is correct
17 Correct 53 ms 15188 KB Output is correct
18 Correct 70 ms 16724 KB Output is correct
19 Correct 488 ms 64960 KB Output is correct
20 Correct 345 ms 57276 KB Output is correct
21 Correct 29 ms 9820 KB Output is correct
22 Correct 317 ms 44996 KB Output is correct