답안 #511427

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
511427 2022-01-15T18:49:58 Z AdamGS 악어의 지하 도시 (IOI11_crocodile) C++14
100 / 100
478 ms 98416 KB
#include "crocodile.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=1e5+7, INF=1e9+7;
vector<pair<int,ll>>V[LIM];
ll mi[LIM], odw[LIM];
int travel_plan(int n, int m, int R[][2], int L[], int k, int P[]) {
	rep(i, n) mi[i]=INF;
	rep(i, m) {
		V[R[i][0]].pb({R[i][1], L[i]});
		V[R[i][1]].pb({R[i][0], L[i]});
	}
	priority_queue<pair<ll,int>>q;
	rep(i, k) q.push({0, P[i]});
	while(!q.empty()) {
		ll o=-q.top().st, a=q.top().nd; q.pop();
		if(odw[a]) continue;
		odw[a]=1;
		if(!a) return o;
		for(auto i : V[a]) {
			if(o+i.nd<=mi[i.st]) {
				if(mi[i.st]!=INF) q.push({-mi[i.st], i.st});
				mi[i.st]=o+i.nd;
			} else {
				q.push({-o-i.nd, i.st});
			}
		}
	}
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:20:30: warning: control reaches end of non-void function [-Wreturn-type]
   20 |  priority_queue<pair<ll,int>>q;
      |                              ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 1 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 3 ms 2764 KB Output is correct
5 Correct 2 ms 2764 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 2 ms 2764 KB Output is correct
8 Correct 2 ms 2764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 1 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 3 ms 2764 KB Output is correct
5 Correct 2 ms 2764 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 2 ms 2764 KB Output is correct
8 Correct 2 ms 2764 KB Output is correct
9 Correct 3 ms 3276 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 3 ms 2924 KB Output is correct
12 Correct 6 ms 4048 KB Output is correct
13 Correct 5 ms 4080 KB Output is correct
14 Correct 2 ms 2656 KB Output is correct
15 Correct 2 ms 2764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 1 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 3 ms 2764 KB Output is correct
5 Correct 2 ms 2764 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 2 ms 2764 KB Output is correct
8 Correct 2 ms 2764 KB Output is correct
9 Correct 3 ms 3276 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 3 ms 2924 KB Output is correct
12 Correct 6 ms 4048 KB Output is correct
13 Correct 5 ms 4080 KB Output is correct
14 Correct 2 ms 2656 KB Output is correct
15 Correct 2 ms 2764 KB Output is correct
16 Correct 447 ms 98416 KB Output is correct
17 Correct 69 ms 15048 KB Output is correct
18 Correct 81 ms 17304 KB Output is correct
19 Correct 460 ms 86060 KB Output is correct
20 Correct 311 ms 88828 KB Output is correct
21 Correct 43 ms 9156 KB Output is correct
22 Correct 478 ms 51520 KB Output is correct