Submission #983194

# Submission time Handle Problem Language Result Execution time Memory
983194 2024-05-15T09:13:23 Z c2zi6 Cyberland (APIO23_cyberland) C++17
5 / 100
1215 ms 2097152 KB
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T>
using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#include "cyberland.h"

typedef vector<vector<pair<int, ld>>> GRAPH;

int n, m, k, h;
GRAPH gp;
VI col;

typedef vector<ld> VD;
typedef vector<VD> VVD;

double solve(int N, int M, int K, int H, VI X, VI Y, VI C, VI ARR) {
	n = N, m = M, k = K, h = H;
	col = ARR;
	gp = GRAPH(n * (k+1));
	rep(i, m) {
		int u = X[i];
		int v = Y[i];
		ld w = C[i];
		gp[u].pb({v, w});
		gp[v].pb({u, w});
		replr(l, 0, k) {
			gp[u + n*l].pb({v + n*l, w});
			gp[v + n*l].pb({u + n*l, w});
			w /= 2;
		}
	}
	
	ld ans = 1e18;
	VD cur(n, 1e18);
	cur[0] = 0;
	for (int i = 0; i < 10; i++) {
		VD nxt(n, 1e18);
		rep(u, n) if (u != h) {
			for (auto[v, w] : gp[u]) {
				setmin(nxt[v], cur[u] + w);
			}
		}
		rep(u, n) if (col[u] == 2) if (nxt[u] != 1e18) nxt[u] /= 2;
		rep(u, n) if (col[u] == 0) if (nxt[u] != 1e18) nxt[u] = 0;
		cur = nxt;
		setmin(ans, cur[h]);
	}
	if (ans == 1e18) return -1;
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 46 ms 556 KB Correct.
2 Correct 45 ms 848 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 140 ms 4992 KB Correct.
2 Incorrect 170 ms 4900 KB Wrong Answer.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 166 ms 4952 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 311 ms 191752 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 143 ms 5140 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 162 ms 5396 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 158 ms 4628 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1215 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -