Submission #519713

# Submission time Handle Problem Language Result Execution time Memory
519713 2022-01-27T06:45:23 Z antonioqbab Crocodile's Underground City (IOI11_crocodile) C++14
100 / 100
470 ms 71108 KB
#include <bits/stdc++.h>
//#include <crocodile.h>

using namespace std;
using ll = long long;
using pi = pair<int,int>;

int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]){
	vector<vector<pair<int,int>>> G(n);
	vector<int> seen(n);
	for(int i=0;i<m;++i){
		int x,y;
		G[r[i][0]].emplace_back(r[i][1], l[i]);
		G[r[i][1]].emplace_back(r[i][0], l[i]);
	}
	auto comp=[&](pi a, pi b){
		return a.second>b.second;
	};
	priority_queue<pi,vector<pi>,decltype(comp)> PQ(comp);
	for(int i=0;i<k;++i){
		PQ.emplace(p[i], 0);
		++seen[p[i]];
	}
	while(!PQ.empty()){
		int node, cost;
		tie(node, cost)=PQ.top();
		PQ.pop();
		if(++seen[node]==2){
			if(node==0)
			return cost;
			for(auto x:G[node])
			PQ.emplace(x.first,x.second+cost);
		}
	}


}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:12:7: warning: unused variable 'x' [-Wunused-variable]
   12 |   int x,y;
      |       ^
crocodile.cpp:12:9: warning: unused variable 'y' [-Wunused-variable]
   12 |   int x,y;
      |         ^
crocodile.cpp:9:35: warning: control reaches end of non-void function [-Wreturn-type]
    9 |  vector<vector<pair<int,int>>> G(n);
      |                                   ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 300 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 332 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 300 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 332 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 1 ms 440 KB Output is correct
12 Correct 5 ms 1100 KB Output is correct
13 Correct 4 ms 1180 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 300 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 332 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 1 ms 440 KB Output is correct
12 Correct 5 ms 1100 KB Output is correct
13 Correct 4 ms 1180 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 316 KB Output is correct
16 Correct 451 ms 71108 KB Output is correct
17 Correct 74 ms 13352 KB Output is correct
18 Correct 79 ms 14796 KB Output is correct
19 Correct 470 ms 66960 KB Output is correct
20 Correct 271 ms 55192 KB Output is correct
21 Correct 36 ms 5804 KB Output is correct
22 Correct 448 ms 44908 KB Output is correct