Submission #920231

# Submission time Handle Problem Language Result Execution time Memory
920231 2024-02-02T10:05:02 Z Mher777 Cyberland (APIO23_cyberland) C++17
15 / 100
3000 ms 1761184 KB
#include "cyberland.h"
#include <iostream>
#include <iomanip>
#include <array>
#include <string>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <list>
#include <iterator>
#include <numeric>
#include <complex>
#include <utility>
#include <random>
#include <fstream>
using namespace std;

/* -------------------- Typedefs -------------------- */

typedef int itn;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef float fl;
typedef long double ld;

/* -------------------- Usings -------------------- */

using vi = vector<int>;
using vll = vector<ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

/* -------------------- Defines -------------------- */

#define ff first
#define ss second
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mpr make_pair
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
#define all(x) (x).begin(), (x).end()

/* -------------------- Constants -------------------- */

const int MAX = int(2e9 + 5);
const ll MAXL = ll(1e18) + 5ll;
const ll MOD = ll(1e9 + 7);
const ll MOD2 = ll(998244353);

const int N = 100005;
vector<pair<int, ld>> g[N];
vector<ld> d[N];
int n, m, k, h;
int used[N];

void dfs(int u = 0) {
	used[u] = 1;
	for (auto to : g[u]) {
		if (!used[to.ff]) dfs(to.ff);
	}
}

void clr() {
	for (int i = 0; i < n; ++i) {
		g[i].clear();
		d[i].clear();
		used[i] = 0;
	}
}

double solve(int N, int M, int K, int H, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr) {
	n = N, m = M, k = K, h = H;
	for (int i = 0; i < m; ++i) {
		g[x[i]].pub({ y[i],(ld)c[i] });
		g[y[i]].pub({ x[i],(ld)c[i] });
	}
	dfs();
	if (!used[h]) {
		clr();
		return -1;
	}
	d[0].resize(k + 1);
	d[0][0] = 0;
	priority_queue<pair<ld, pii>> pq;
	pq.push({ 0,{0,0} });
	for (int i = 1; i < n; ++i) {
		if (used[i]) d[i].resize(k + 1);
		else continue;
		for (int j = 0; j <= k; ++j) d[i][j] = (ld)MAXL;
		if (!arr[i]) {
			pq.push({ 0,{i,0} });
			d[i][0] = 0;
		}
	}
	while (!pq.empty()) {
		int u = pq.top().ss.ff;
		int ind = pq.top().ss.ss;
		ld w = -pq.top().ff;
		pq.pop();
		if (w > d[u][ind]) continue;
		for (auto to : g[u]) {
			if (d[to.ff][ind] > d[u][ind] + to.ss) {
				d[to.ff][ind] = d[u][ind] + to.ss;
				pq.push({ -d[to.ff][ind],{to.ff,ind} });
			}
			if (arr[to.ff] == 2 && ind != k) {
				if (d[to.ff][ind + 1] > (d[u][ind] + to.ss / (ld)2)) {
					d[to.ff][ind + 1] = (d[u][ind] + to.ss / (ld)2);
					pq.push({ -d[to.ff][ind + 1],{to.ff,ind + 1} });
				}
			}
		}
	}
	ld ans = d[h][0];
	for (int i = 1; i <= k; ++i) {
		ans = min(ans, d[h][i]);
	}
	clr();
	return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 5464 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 25 ms 6084 KB Correct.
2 Correct 29 ms 5976 KB Correct.
3 Correct 29 ms 6112 KB Correct.
4 Correct 29 ms 5980 KB Correct.
5 Correct 31 ms 5976 KB Correct.
6 Correct 30 ms 11612 KB Correct.
7 Correct 39 ms 11620 KB Correct.
8 Correct 21 ms 17752 KB Correct.
9 Correct 27 ms 5468 KB Correct.
10 Correct 26 ms 5464 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 5976 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1040 ms 51444 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 7084 KB Correct.
2 Correct 24 ms 7256 KB Correct.
3 Correct 23 ms 7256 KB Correct.
4 Correct 33 ms 12540 KB Correct.
5 Correct 20 ms 6232 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 7000 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 211 ms 8052 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3110 ms 1761184 KB Time limit exceeded
2 Halted 0 ms 0 KB -