Submission #462502

# Submission time Handle Problem Language Result Execution time Memory
462502 2021-08-10T16:15:28 Z fuad27 Crocodile's Underground City (IOI11_crocodile) C++14
100 / 100
597 ms 61208 KB
    #include<bits/stdc++.h>
#include"crocodile.h"
    using namespace std;
    int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
    	vector<vector<pair<int, int>>> adj(N);
    	for(int i = 0; i < M; i++) {
    		int u = R[i][0], v = R[i][1];
    		adj[u].emplace_back(v, L[i]);
    		adj[v].emplace_back(u, L[i]);
    	}
     
    	vector<int> visited(N);
    	priority_queue<pair<int, int>> q;
    	for(int i = 0; i < K; i++) {
    		visited[P[i]]++;
    		q.emplace(0, P[i]);
    	}
     
    	while(!q.empty()) {
    		auto [d, v] = q.top();
    		q.pop();
    		if(visited[v]++ == 1) {
    			if(v == 0) return -d;
    			for(auto &[u, w] : adj[v])
    				q.emplace(d - w, u);
    		}
    	}
	return -1; 
    }

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:20:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   20 |       auto [d, v] = q.top();
      |            ^
crocodile.cpp:24:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   24 |        for(auto &[u, w] : adj[v])
      |                  ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 2 ms 588 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 2 ms 460 KB Output is correct
12 Correct 6 ms 1108 KB Output is correct
13 Correct 4 ms 1228 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 2 ms 588 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 2 ms 460 KB Output is correct
12 Correct 6 ms 1108 KB Output is correct
13 Correct 4 ms 1228 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 536 ms 61208 KB Output is correct
17 Correct 92 ms 13232 KB Output is correct
18 Correct 103 ms 14828 KB Output is correct
19 Correct 597 ms 56940 KB Output is correct
20 Correct 360 ms 57756 KB Output is correct
21 Correct 50 ms 5892 KB Output is correct
22 Correct 591 ms 36744 KB Output is correct