Submission #900319

# Submission time Handle Problem Language Result Execution time Memory
900319 2024-01-08T06:39:30 Z Muhammad_Aneeq Crocodile's Underground City (IOI11_crocodile) C++17
46 / 100
40 ms 6372 KB
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
long long const MAXN=1e5+10;
vector<pair<int,int>>nei[MAXN]={};
bool ex[MAXN]={};
bool vis1[MAXN]={};
map<pair<int,int>,long long>vis,value;
bool comp(pair<int,int>a,pair<int,int>b)
{
	return (a.second<=b.second);
}
long long  dfs(long long n,long long  val)
{
	if (ex[n])
		return val;
	vis1[n]=1;
	vector<int>g;
	long long  mn1=1e15+10,mn2=1e15+10;
	for (auto [i,w1]:nei[n])
	{
		if (!vis1[i])
		{
			long long z;
			if (vis[{i,n}]==0)
			{
				z=dfs(i,val+w1);
				value[{i,n}]=z-val;
				vis[{i,n}]=1;
			}
			else
			{
				z=value[{i,n}]+val;
			}
			if (z<mn1)
			{
				mn2=mn1;
				mn1=z;
			}
			else if (mn2>z)
				mn2=z;
		}
	}
	vis1[n]=0;
	return mn2;
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
	for (int i=0;i<M;i++)
	{
		nei[R[i][0]].push_back({R[i][1],L[i]});
		nei[R[i][1]].push_back({R[i][0],L[i]});
	}
	for  (int i=0;i<K;i++)
		ex[P[i]]=1;
	for (int i=0;i<N;i++)
		sort(begin(nei[i]),end(nei[i]),comp);
	return dfs(0,0);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5208 KB Output is correct
2 Correct 3 ms 5212 KB Output is correct
3 Correct 1 ms 5212 KB Output is correct
4 Correct 2 ms 5468 KB Output is correct
5 Correct 2 ms 5360 KB Output is correct
6 Correct 2 ms 5468 KB Output is correct
7 Correct 2 ms 5468 KB Output is correct
8 Correct 2 ms 5468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5208 KB Output is correct
2 Correct 3 ms 5212 KB Output is correct
3 Correct 1 ms 5212 KB Output is correct
4 Correct 2 ms 5468 KB Output is correct
5 Correct 2 ms 5360 KB Output is correct
6 Correct 2 ms 5468 KB Output is correct
7 Correct 2 ms 5468 KB Output is correct
8 Correct 2 ms 5468 KB Output is correct
9 Correct 40 ms 6372 KB Output is correct
10 Correct 1 ms 5212 KB Output is correct
11 Incorrect 11 ms 5880 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5208 KB Output is correct
2 Correct 3 ms 5212 KB Output is correct
3 Correct 1 ms 5212 KB Output is correct
4 Correct 2 ms 5468 KB Output is correct
5 Correct 2 ms 5360 KB Output is correct
6 Correct 2 ms 5468 KB Output is correct
7 Correct 2 ms 5468 KB Output is correct
8 Correct 2 ms 5468 KB Output is correct
9 Correct 40 ms 6372 KB Output is correct
10 Correct 1 ms 5212 KB Output is correct
11 Incorrect 11 ms 5880 KB Output isn't correct
12 Halted 0 ms 0 KB -