Submission #411792

# Submission time Handle Problem Language Result Execution time Memory
411792 2021-05-26T01:30:20 Z jeqcho Crocodile's Underground City (IOI11_crocodile) C++17
46 / 100
136 ms 262148 KB
//#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpi;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define pb push_back
#define rsz resize
#define sz(x) int(x.size())
#define all(x) begin(x), end(x)
#define fi first
#define se second

int const n=1e5+3;
bitset<n> out;
vpi adj[n];

ll dfs(int now, int par)
{
	if(out[now])return 0;
	ll mn1=2e18;
	ll mn2=2e18;
	trav(chi,adj[now])
	{
		if(chi.fi==par)continue;
		ll cand = dfs(chi.fi,now)+(ll)chi.se;
		if(cand<mn1)
		{
			mn2=mn1;
			mn1=cand;
		}
		else
		{
			mn2=min(mn2,cand);
		}
	}
	
	return mn2;
}

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
	F0R(i,K)
	{
		out[P[i]]=1;
	}
	F0R(i,M)
	{
		int u=R[i][0];
		int v=R[i][1];
		adj[u].pb({v,L[i]});
		adj[v].pb({u,L[i]});
	}
	return (int)dfs(0,-1);
}


# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2656 KB Output is correct
4 Correct 3 ms 2636 KB Output is correct
5 Correct 3 ms 2636 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 3 ms 2636 KB Output is correct
8 Correct 3 ms 2664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2656 KB Output is correct
4 Correct 3 ms 2636 KB Output is correct
5 Correct 3 ms 2636 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 3 ms 2636 KB Output is correct
8 Correct 3 ms 2664 KB Output is correct
9 Runtime error 136 ms 262148 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2656 KB Output is correct
4 Correct 3 ms 2636 KB Output is correct
5 Correct 3 ms 2636 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 3 ms 2636 KB Output is correct
8 Correct 3 ms 2664 KB Output is correct
9 Runtime error 136 ms 262148 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -