Submission #1002275

# Submission time Handle Problem Language Result Execution time Memory
1002275 2024-06-19T11:46:42 Z ZeroCool Crocodile's Underground City (IOI11_crocodile) C++14
100 / 100
377 ms 68332 KB
#include "crocodile.h"
#include <bits/stdc++.h>

using namespace std;


#define ll long long
#define ar array

const ll INF = 1e17;

int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]){
	vector<ar<int, 2> > g[n];
	for(int i = 0;i <m;i++){
		g[r[i][0]].push_back({r[i][1], l[i]});
		g[r[i][1]].push_back({r[i][0], l[i]});
	}
	
	ar<ll, 2> dist[n];
	bool vis[n];
	for(int i = 0;i < n;i++)dist[i] = {INF, INF}, vis[i] = 0;
	
	priority_queue<ar<ll, 2> > q;
	for(int i = 0;i < k;i++){
		q.push({0, p[i]});
		dist[p[i]] = {0, 0};
	}
	
	while(q.size()){
		int x = q.top()[1];
		q.pop();
		
		if(vis[x])continue;
		vis[x] = 1;
		
		for(auto [u, w]: g[x]){
			if(dist[u][0] > dist[x][1] + w){
				dist[u][1] = dist[u][0];
				dist[u][0] = dist[x][1] +w ;
				q.push({-dist[u][1], u});
			}else if(dist[u][1] > dist[x][1] +w ){
				dist[u][1] = dist[x][1] + w;
				q.push({-dist[u][1], u});
			}
			
		}
	}
	return dist[0][1];
}


Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:36:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   36 |   for(auto [u, w]: g[x]){
      |            ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 3 ms 600 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 3 ms 860 KB Output is correct
13 Correct 2 ms 836 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 3 ms 600 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 3 ms 860 KB Output is correct
13 Correct 2 ms 836 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 248 ms 59332 KB Output is correct
17 Correct 62 ms 16888 KB Output is correct
18 Correct 79 ms 18380 KB Output is correct
19 Correct 377 ms 68332 KB Output is correct
20 Correct 163 ms 47440 KB Output is correct
21 Correct 27 ms 6860 KB Output is correct
22 Correct 188 ms 45172 KB Output is correct