Submission #261849

# Submission time Handle Problem Language Result Execution time Memory
261849 2020-08-12T06:37:41 Z Sakamotoo Crocodile's Underground City (IOI11_crocodile) C++14
89 / 100
1014 ms 91008 KB
#include "crocodile.h"
#include<bits/stdc++.h>
using namespace std;

#define mp make_pair
#define fi first
#define se second

int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]){
	priority_queue<long long> jar[n+1];
	vector<pair<long long, long long> > adj[n+1];
	for(int i=0; i<m; i++){
		adj[r[i][0]].push_back(mp(r[i][1],l[i]));
		adj[r[i][1]].push_back(mp(r[i][0],l[i]));
	}
	
	priority_queue<pair<long long, long long> > pq;
	
	for(int i=0; i<k; i++){
		jar[p[i]].push(0);
		jar[p[i]].push(0);
		pq.push(mp(0,p[i]));
	}
	
	while(!pq.empty()){
		long long x=-pq.top().fi,y=pq.top().se;
		pq.pop();
		if(jar[y].top()<x) continue;
		for(int i=0; i<adj[y].size(); i++){
			long long ind=adj[y][i].fi,cost=adj[y][i].se;
			if(jar[ind].size()<2){
				jar[ind].push(x+cost);
				if(jar[ind].size()==2){
					pq.push(mp(-jar[ind].top(),ind));
				}
			}else{
				if(jar[ind].top()>x+cost){
					jar[ind].pop();
					jar[ind].push(x+cost);
					pq.push(mp(-jar[ind].top(),ind));
				}
			}
		}
	}
	return jar[0].top();
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:29:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0; i<adj[y].size(); i++){
                ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 512 KB Output is correct
8 Correct 1 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 512 KB Output is correct
8 Correct 1 ms 512 KB Output is correct
9 Correct 3 ms 768 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 5 ms 1024 KB Output is correct
13 Correct 4 ms 1152 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 2 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 512 KB Output is correct
8 Correct 1 ms 512 KB Output is correct
9 Correct 3 ms 768 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 5 ms 1024 KB Output is correct
13 Correct 4 ms 1152 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 2 ms 512 KB Output is correct
16 Correct 746 ms 81772 KB Output is correct
17 Correct 118 ms 22392 KB Output is correct
18 Correct 186 ms 24056 KB Output is correct
19 Correct 1014 ms 91008 KB Output is correct
20 Correct 388 ms 65144 KB Output is correct
21 Correct 58 ms 9592 KB Output is correct
22 Incorrect 421 ms 63792 KB Output isn't correct