Submission #979888

# Submission time Handle Problem Language Result Execution time Memory
979888 2024-05-11T14:40:39 Z SmuggingSpun Crocodile's Underground City (IOI11_crocodile) C++14
89 / 100
2000 ms 62484 KB
#include "crocodile.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
struct Data{
	int vertex;
	pair<ll, ll>value;
	Data(int vertex, pair<ll, ll>value){
		this->vertex = vertex;
		this->value = value;
	}
	friend bool operator <(const Data a, const Data b){
		return a.value.second > b.value.second;
	}
};
template<class T>bool minimize(T& a, T b){
	if(a > b){
		a = b;
		return true;
	}
	return false;
}
const int lim = 1e5 + 5;
int travel_plan(int n, int m, int R[][2], int L[], int k, int P[]){
	vector<vector<int>>e(n);
	vector<pair<ll, ll>>dp(n, make_pair(INF, INF));
	for(int i = 0; i < m; i++){
		e[R[i][0]].emplace_back(i);
		e[R[i][1]].emplace_back(i);
	}
	priority_queue<Data>pq;
	for(int i = 0; i < k; i++){
		pq.emplace(P[i], dp[P[i]] = make_pair(0, 0));
	}
	while(!pq.empty()){
		auto [u, W] = pq.top();
		pq.pop();
		cerr << u << " " << W.first << " " << W.second << endl;
		if(W == dp[u]){
			for(int i = 0; i < e[u].size(); i++){
				int v = R[e[u][i]][0] ^ R[e[u][i]][1] ^ u;
				ll w = W.second + L[e[u][i]];
				if(minimize(dp[v], make_pair(w, dp[v].first)) || minimize(dp[v], make_pair(dp[v].first, w))){
					pq.emplace(v, dp[v]);
				}
			}
		}
	}
	return dp[0].second;
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:37:8: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   37 |   auto [u, W] = pq.top();
      |        ^
crocodile.cpp:41:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |    for(int i = 0; i < e[u].size(); i++){
      |                   ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 4 ms 4444 KB Output is correct
4 Correct 11 ms 4444 KB Output is correct
5 Correct 11 ms 4688 KB Output is correct
6 Correct 7 ms 4440 KB Output is correct
7 Correct 11 ms 4680 KB Output is correct
8 Correct 11 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 4 ms 4444 KB Output is correct
4 Correct 11 ms 4444 KB Output is correct
5 Correct 11 ms 4688 KB Output is correct
6 Correct 7 ms 4440 KB Output is correct
7 Correct 11 ms 4680 KB Output is correct
8 Correct 11 ms 4444 KB Output is correct
9 Correct 8 ms 4700 KB Output is correct
10 Correct 4 ms 4440 KB Output is correct
11 Correct 6 ms 4444 KB Output is correct
12 Correct 11 ms 4700 KB Output is correct
13 Correct 5 ms 4700 KB Output is correct
14 Correct 4 ms 4592 KB Output is correct
15 Correct 7 ms 4504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 4 ms 4444 KB Output is correct
4 Correct 11 ms 4444 KB Output is correct
5 Correct 11 ms 4688 KB Output is correct
6 Correct 7 ms 4440 KB Output is correct
7 Correct 11 ms 4680 KB Output is correct
8 Correct 11 ms 4444 KB Output is correct
9 Correct 8 ms 4700 KB Output is correct
10 Correct 4 ms 4440 KB Output is correct
11 Correct 6 ms 4444 KB Output is correct
12 Correct 11 ms 4700 KB Output is correct
13 Correct 5 ms 4700 KB Output is correct
14 Correct 4 ms 4592 KB Output is correct
15 Correct 7 ms 4504 KB Output is correct
16 Correct 1709 ms 51540 KB Output is correct
17 Correct 1402 ms 23372 KB Output is correct
18 Correct 1418 ms 24492 KB Output is correct
19 Execution timed out 2011 ms 62484 KB Time limit exceeded
20 Halted 0 ms 0 KB -