답안 #815605

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
815605 2023-08-08T17:24:24 Z OAleksa 악어의 지하 도시 (IOI11_crocodile) C++14
89 / 100
2000 ms 143832 KB
#include <bits/stdc++.h>
//#include "factories.h"
#include "crocodile.h"
#define f first
#define s second
using namespace std; 
const int maxn = 1e5 + 69;
set<pair<int, int>> g[maxn];
vector<int> d(maxn, 1e9);
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
  	for(int i = 0;i < M;i++) {
  		g[R[i][0]].insert({R[i][1], L[i]});
  		g[R[i][1]].insert({R[i][0], L[i]});
  	}
  	priority_queue<pair<int, int>> pq;
  	for(int i = 0;i < K;i++) {
  		for(auto u : g[P[i]]) 
  			pq.push({-u.s, u.f});
  		d[P[i]] = 0;
  	}
  	vector<int> cnt(N);
  	while(!pq.empty()) {
  		auto u = pq.top();
  		pq.pop();
  		if(d[u.s] != 1e9)
  			continue;
  		cnt[u.s]++;
  		if(cnt[u.s] == 2) {
  			d[u.s] = -u.f;
  			for(auto v : g[u.s])
  				pq.push({-v.s + u.f, v.f});
  		}
  	}
  	return d[0];
}



// int main()
// {
	// ios_base::sync_with_stdio(false);
	// cin.tie(0);
	// cout.tie(0);
	// int tt = 1;
	// //cin >> tt;
	// while(tt--) {
		// int n, m;
		// cin >> n >> m;
		// int r[m][2];
		// for(int i = 0;i < m;i++)
			// cin >> r[i][0] >> r[i][1];
		// int l[m];
		// for(int i = 0;i < m;i++)
			// cin >> l[i];
		// int k;
		// cin >> k;
		// int p[k];
		// for(int i = 0;i < k;i++)
			// cin >> p[i];
		// cout << travel_plan(n, m, r, l, k, p);
	// }
   // return 0;
// }
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5332 KB Output is correct
2 Correct 2 ms 5420 KB Output is correct
3 Correct 3 ms 5424 KB Output is correct
4 Correct 3 ms 5460 KB Output is correct
5 Correct 3 ms 5460 KB Output is correct
6 Correct 3 ms 5428 KB Output is correct
7 Correct 3 ms 5460 KB Output is correct
8 Correct 3 ms 5436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5332 KB Output is correct
2 Correct 2 ms 5420 KB Output is correct
3 Correct 3 ms 5424 KB Output is correct
4 Correct 3 ms 5460 KB Output is correct
5 Correct 3 ms 5460 KB Output is correct
6 Correct 3 ms 5428 KB Output is correct
7 Correct 3 ms 5460 KB Output is correct
8 Correct 3 ms 5436 KB Output is correct
9 Correct 7 ms 6100 KB Output is correct
10 Correct 4 ms 5460 KB Output is correct
11 Correct 4 ms 5716 KB Output is correct
12 Correct 14 ms 6972 KB Output is correct
13 Correct 8 ms 6868 KB Output is correct
14 Correct 3 ms 5388 KB Output is correct
15 Correct 5 ms 5580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5332 KB Output is correct
2 Correct 2 ms 5420 KB Output is correct
3 Correct 3 ms 5424 KB Output is correct
4 Correct 3 ms 5460 KB Output is correct
5 Correct 3 ms 5460 KB Output is correct
6 Correct 3 ms 5428 KB Output is correct
7 Correct 3 ms 5460 KB Output is correct
8 Correct 3 ms 5436 KB Output is correct
9 Correct 7 ms 6100 KB Output is correct
10 Correct 4 ms 5460 KB Output is correct
11 Correct 4 ms 5716 KB Output is correct
12 Correct 14 ms 6972 KB Output is correct
13 Correct 8 ms 6868 KB Output is correct
14 Correct 3 ms 5388 KB Output is correct
15 Correct 5 ms 5580 KB Output is correct
16 Execution timed out 2066 ms 143832 KB Time limit exceeded
17 Halted 0 ms 0 KB -