Submission #483681

# Submission time Handle Problem Language Result Execution time Memory
483681 2021-10-31T17:07:38 Z PoPularPlusPlus Crocodile's Underground City (IOI11_crocodile) C++17
89 / 100
513 ms 77060 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long 
#define pb(e) push_back(e)
#define sv(a) sort(a.begin(),a.end())
#define sa(a,n) sort(a,a+n)
#define mp(a,b) make_pair(a,b)
#define vf first
#define vs second
#define ar array
#define all(x) x.begin(),x.end()
const int inf = 0x3f3f3f3f;
const int mod = 1000000007; 
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
bool remender(ll a , ll b){return a%b;}

vector<pair<int,ll>	> adj[100002];
ll dp[100002],dp1[100002];

void Dijkstra(int p[] , int k){
	 priority_queue< pair<ll,ll>, vector <pair<ll,ll>> , greater<pair<ll,ll>> > pq; 
	 for(int e = 0; e < k; e++){
		 dp[p[e]] = dp1[p[e]] = 0;
		 pq.push({dp1[p[e]] , p[e]});
	 }
	 while(!pq.empty()){
		 ll node = pq.top().second,ww=pq.top().first;
		 pq.pop();
		 if(dp1[node] < ww)continue;
		 for(auto i : adj[node]){
			 ll w = i.second;
			 if(dp[i.first] >ww + w){
				 dp1[i.vf] = dp[i.vf];
				 dp[i.vf] = ww + w;
				 pq.push({dp1[i.first],i.first});
			 }
			 else if(dp1[i.vf] > ww + w){
				 dp1[i.vf] = ww + w;
				 pq.push({dp1[i.first],i.first});
			 }
		 }
	 }
}

int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]){
	for(int i = 0; i < m; i++){
		adj[r[i][0]].pb(mp(r[i][1] , l[i]));
		adj[r[i][1]].pb(mp(r[i][0] , l[i]));
	}
	for(int i = 0; i < n; i++)dp[i] = dp1[i] = 1e12;
	Dijkstra(p,k);
	/*for(int i = 0; i < n; i++){
		cout << dp[i] << ' ' << dp1[i] << '\n';
	}*/
	return dp1[0];
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 1 ms 2636 KB Output is correct
3 Correct 1 ms 2636 KB Output is correct
4 Correct 2 ms 2764 KB Output is correct
5 Correct 2 ms 2764 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 2 ms 2764 KB Output is correct
8 Correct 2 ms 2764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 1 ms 2636 KB Output is correct
3 Correct 1 ms 2636 KB Output is correct
4 Correct 2 ms 2764 KB Output is correct
5 Correct 2 ms 2764 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 2 ms 2764 KB Output is correct
8 Correct 2 ms 2764 KB Output is correct
9 Correct 4 ms 3012 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 3 ms 2764 KB Output is correct
12 Correct 4 ms 3276 KB Output is correct
13 Correct 5 ms 3404 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 2 ms 2764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 1 ms 2636 KB Output is correct
3 Correct 1 ms 2636 KB Output is correct
4 Correct 2 ms 2764 KB Output is correct
5 Correct 2 ms 2764 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 2 ms 2764 KB Output is correct
8 Correct 2 ms 2764 KB Output is correct
9 Correct 4 ms 3012 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 3 ms 2764 KB Output is correct
12 Correct 4 ms 3276 KB Output is correct
13 Correct 5 ms 3404 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 2 ms 2764 KB Output is correct
16 Correct 385 ms 68776 KB Output is correct
17 Correct 89 ms 16576 KB Output is correct
18 Correct 105 ms 18756 KB Output is correct
19 Correct 513 ms 77060 KB Output is correct
20 Correct 263 ms 55104 KB Output is correct
21 Correct 38 ms 8920 KB Output is correct
22 Incorrect 266 ms 50372 KB Output isn't correct