답안 #851274

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
851274 2023-09-19T09:24:46 Z Halym2007 악어의 지하 도시 (IOI11_crocodile) C++17
100 / 100
474 ms 55076 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 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 2 ms 6488 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 2 ms 6488 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 3 ms 7000 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 5 ms 6852 KB Output is correct
13 Correct 4 ms 7092 KB Output is correct
14 Correct 1 ms 6488 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 2 ms 6488 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 3 ms 7000 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 2 ms 6492 KB Output is correct
12 Correct 5 ms 6852 KB Output is correct
13 Correct 4 ms 7092 KB Output is correct
14 Correct 1 ms 6488 KB Output is correct
15 Correct 2 ms 6492 KB Output is correct
16 Correct 437 ms 53512 KB Output is correct
17 Correct 55 ms 13396 KB Output is correct
18 Correct 71 ms 14508 KB Output is correct
19 Correct 474 ms 55076 KB Output is correct
20 Correct 345 ms 49344 KB Output is correct
21 Correct 29 ms 8796 KB Output is correct
22 Correct 324 ms 37748 KB Output is correct