Submission #672550

# Submission time Handle Problem Language Result Execution time Memory
672550 2022-12-16T15:12:52 Z mmk Crocodile's Underground City (IOI11_crocodile) C++14
46 / 100
4 ms 5076 KB
#include "crocodile.h"
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f3f3f3f3f
#define ll long long
using namespace std;
const ll MAXN = 1e5+10;
ll Dist1[MAXN], Dist2[MAXN];
int marc[MAXN];
vector<ll> grafo[MAXN];
vector<ll> weight[MAXN];
int travel_plan(int n, int m, int R[][2], int L[], int K, int P[])
{
	for(int i = 0; i < n; i++)
	{
		ll a = R[i][0];
		ll b = R[i][1];
		grafo[a].push_back(b);
		grafo[b].push_back(a);
		weight[a].push_back(L[i]);
		weight[b].push_back(L[i]);
	}
	
	set<pair<ll,ll>> s;
	for(int i = 0; i < n; i++)
	{
		Dist1[i] = INF;
		Dist2[i] = INF;
	}
	for(int i = 0; i < K; i++)
	{
		Dist1[P[i]] = 0;
		Dist2[P[i]] = 0;
		s.insert({0,P[i]});
	}
	while(!s.empty())
	{
		ll cur = s.begin()->second;
		s.erase(s.begin());
		if(marc[cur] == 1) continue;
		marc[cur] = 1;
		for(ll i = 0; i < grafo[cur].size(); i++)
		{
			ll viz = grafo[cur][i];
			ll p = weight[cur][i];
			if(Dist2[cur] + p < Dist1[viz])
			{
				Dist2[viz] = Dist1[viz];
				Dist1[viz] = Dist2[cur] + p;
				s.insert({Dist2[viz],viz});
			}
			else if(Dist2[cur] + p < Dist2[viz])
			{
				Dist2[viz] = Dist2[cur] + p;
				s.insert({Dist2[viz],viz});
			}
		}
	}
	return Dist2[0];
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:41:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |   for(ll i = 0; i < grafo[cur].size(); i++)
      |                 ~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 5076 KB Output is correct
4 Correct 3 ms 5076 KB Output is correct
5 Correct 3 ms 5076 KB Output is correct
6 Correct 3 ms 5076 KB Output is correct
7 Correct 3 ms 5076 KB Output is correct
8 Correct 3 ms 5076 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 5076 KB Output is correct
4 Correct 3 ms 5076 KB Output is correct
5 Correct 3 ms 5076 KB Output is correct
6 Correct 3 ms 5076 KB Output is correct
7 Correct 3 ms 5076 KB Output is correct
8 Correct 3 ms 5076 KB Output is correct
9 Incorrect 4 ms 5076 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 5076 KB Output is correct
4 Correct 3 ms 5076 KB Output is correct
5 Correct 3 ms 5076 KB Output is correct
6 Correct 3 ms 5076 KB Output is correct
7 Correct 3 ms 5076 KB Output is correct
8 Correct 3 ms 5076 KB Output is correct
9 Incorrect 4 ms 5076 KB Output isn't correct
10 Halted 0 ms 0 KB -