Submission #867183

# Submission time Handle Problem Language Result Execution time Memory
867183 2023-10-27T20:11:36 Z thegamercoder19 Crocodile's Underground City (IOI11_crocodile) C++14
46 / 100
152 ms 262144 KB
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846
#define FILER 0
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const ll MOD = pow(10, 9) + 7;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const ull INFUL = 0x3f3f3f3f3f3f3f3f;
const ll INFT = 0x3f3f3f3f;
const ull MAX = 1LL << 24;
const ll MODD = 998244353;
const double EPS = 1e-10;
#define V vector
#define pll pair<ll, ll>
#define pull2 pair<ull,ull>
#define MS multiset
//#define M map
#define Q queue
#define PQ priority_queue
#define IOF ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FOR(typ,i,a,b,c) for(typ i = a; i < b; i += c)
#define FORR(typ,i,a,b,c) for(typ i = a; i > b; i -= c)
#define FORA(a,i) for(auto &i : a)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define sorta(a) sort(all(a))
#define sortd(a) sort(all(a), greater<ll>())
#define setp(x) setprecision(x)<<fixed
#define RET return
#define log(a,b) log(b)/log(a)
#define WH(s) while(s)
#define WHI(t) WH(t--)
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define YESNO(s) cout << (s ? "YES" : "NO") << endl;
#define YesNo(s) cout<<(s?"Yes":"No")<<endl;
#define TYP 0
using namespace std;
#include "crocodile.h"
V<V<pll>> g;
V<ll> dp;

void dfs(ll u, ll p)
{
	ll m = INFL, mu = -1;
	FORA(g[u], v)
		if (v.first != p)
		{
			dfs(v.first, u);
			if (m > dp[v.first] + v.second)
				mu = v.first, m = dp[v.first] + v.second;
	    }
	if (g[u].size() != 1)
	{
		m = INFL;
		FORA(g[u], v)
			if (v.first != p && v.first != mu)
				m = min(m, dp[v.first] + v.second);
		dp[u] = m;
	}

}

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
	g.resize(N + 1); dp.resize(N + 1);
	FOR(ll, i, 0, M, 1)g[R[i][0]].push_back({ R[i][1], L[i] }), g[R[i][1]].push_back({ R[i][0], L[i] });
	dfs(0, -1);
	RET dp[0];
}


# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4544 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4440 KB Output is correct
6 Correct 1 ms 4440 KB Output is correct
7 Correct 1 ms 4548 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4544 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4440 KB Output is correct
6 Correct 1 ms 4440 KB Output is correct
7 Correct 1 ms 4548 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Runtime error 152 ms 262144 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4544 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4440 KB Output is correct
6 Correct 1 ms 4440 KB Output is correct
7 Correct 1 ms 4548 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Runtime error 152 ms 262144 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -