Submission #261857

# Submission time Handle Problem Language Result Execution time Memory
261857 2020-08-12T06:42:08 Z Sakamotoo Crocodile's Underground City (IOI11_crocodile) C++14
89 / 100
930 ms 74664 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;
		if(x>1e9) 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:30: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 2 ms 512 KB Output is correct
5 Correct 1 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 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 2 ms 512 KB Output is correct
5 Correct 1 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 2 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 4 ms 896 KB Output is correct
13 Correct 4 ms 1024 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 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 2 ms 512 KB Output is correct
5 Correct 1 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 2 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 4 ms 896 KB Output is correct
13 Correct 4 ms 1024 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 512 KB Output is correct
16 Correct 632 ms 65744 KB Output is correct
17 Correct 115 ms 19064 KB Output is correct
18 Correct 149 ms 20580 KB Output is correct
19 Correct 930 ms 74664 KB Output is correct
20 Correct 370 ms 52348 KB Output is correct
21 Correct 51 ms 8188 KB Output is correct
22 Incorrect 434 ms 49736 KB Output isn't correct