Submission #393845

# Submission time Handle Problem Language Result Execution time Memory
393845 2021-04-24T16:40:32 Z keko37 Escape Route (JOI21_escape_route) C++17
5 / 100
9000 ms 112000 KB
#include<bits/stdc++.h>
#include "escape_route.h"

using namespace std;

typedef long long llint;
typedef pair <llint, llint> pi;
typedef vector <int> Vi;
typedef vector <llint> vi;

const int MAXN = 91;
const int MAXM = 91 * 91; 
const llint INF = 1000000000000000000LL;

llint n, m, s, q, br;
llint len[MAXM], c[MAXM];
llint path[MAXN][MAXN], bio[MAXN][MAXN];
vector <pi> v[MAXN];

void dijkstra (int root, llint d) {
	for (int i = 0; i < n; i++) {
		path[root][i] = INF;
		bio[root][i] = 0;
	}
	path[root][root] = d;
	for (int i = 0; i < n; i++) {
		llint mn = INF, ind = -1;
		for (int j = 0; j < n; j++) {
			if (bio[root][j] == 0 && path[root][j] < mn) {
				mn = path[root][j];
				ind = j;
			}
		}
		bio[root][ind] = 1;
		for (auto pp : v[ind]) {
			int sus = pp.first, e = pp.second;
			llint novi = path[root][ind] + len[e];
			if (path[root][ind] % s <= c[e] - len[e]) {
				path[root][sus] = min(path[root][sus], novi);
			}
			novi += s - path[root][ind] % s;
			path[root][sus] = min(path[root][sus], novi);
		}
	}
}

vi calculate_necessary_time (int N, int M, llint S, int Q, 
							 Vi A, Vi B, vi L, vi C, Vi U, Vi V, vi T) {
	n = N; m = M; s = S; q = Q;
	for (int i = 0; i < m; i++) {
		len[i] = L[i];
		c[i] = C[i];
		v[A[i]].push_back({B[i], i});
		v[B[i]].push_back({A[i], i});
	}
	vi sol;
	for (int i = 0; i < q; i++) {
		dijkstra(U[i], T[i]);
		sol.push_back(path[U[i]][V[i]] - T[i]);
	}
	return sol;
}
# Verdict Execution time Memory Grader output
1 Correct 31 ms 65024 KB Output is correct
2 Correct 38 ms 64948 KB Output is correct
3 Correct 51 ms 65104 KB Output is correct
4 Correct 29 ms 64936 KB Output is correct
5 Correct 40 ms 65000 KB Output is correct
6 Correct 35 ms 64972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 9085 ms 112000 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 31 ms 65024 KB Output is correct
2 Correct 38 ms 64948 KB Output is correct
3 Correct 51 ms 65104 KB Output is correct
4 Correct 29 ms 64936 KB Output is correct
5 Correct 40 ms 65000 KB Output is correct
6 Correct 35 ms 64972 KB Output is correct
7 Execution timed out 9085 ms 112000 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 31 ms 65024 KB Output is correct
2 Correct 38 ms 64948 KB Output is correct
3 Correct 51 ms 65104 KB Output is correct
4 Correct 29 ms 64936 KB Output is correct
5 Correct 40 ms 65000 KB Output is correct
6 Correct 35 ms 64972 KB Output is correct
7 Execution timed out 9085 ms 112000 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 31 ms 65024 KB Output is correct
2 Correct 38 ms 64948 KB Output is correct
3 Correct 51 ms 65104 KB Output is correct
4 Correct 29 ms 64936 KB Output is correct
5 Correct 40 ms 65000 KB Output is correct
6 Correct 35 ms 64972 KB Output is correct
7 Execution timed out 9085 ms 112000 KB Time limit exceeded
8 Halted 0 ms 0 KB -