Submission #674243

# Submission time Handle Problem Language Result Execution time Memory
674243 2022-12-23T14:13:19 Z mdub Race (IOI11_race) C++14
9 / 100
55 ms 9052 KB
#include <bits/stdc++.h>

using namespace std;

struct Edge {
	int to; int weight;
};

int n; int k;
vector<vector<Edge>> g;
vector<bool> seen;
map<int, stack<int>> mp;
vector<int> weights;
int ans;
void dfs(int iNode, int sum, int stage) {
	seen[iNode] = true;
	mp[sum].push(stage);
	if (!mp[sum- k].empty())
	    ans = min(ans, stage - mp[sum- k].top());

	for (auto adj: g[iNode]) {
		if (!seen[adj.to]) {
			dfs(adj.to, sum+adj.weight, stage + 1);
		}
	}
	mp[sum].pop();
	
			
}	

int best_path(int n2, int k2, int h[][2] , int l[] ) {
    n = n2; k = k2;
	g.resize(n);
	seen.assign(n, 0);
	ans = 1e9;
	for (int i = 0; i < n - 1; i++) {
		int n1 = h[i][0], n2 = h[i][1];
		g[n1].push_back({n2, l[i]});
		g[n2].push_back({n1, l[i]});
	}

	dfs(0, 0, 0);
	if (ans == 1e9) return -1;
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 428 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 436 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 432 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 352 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 428 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 436 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 432 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 352 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Incorrect 0 ms 212 KB Output isn't correct
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 428 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 436 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 432 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 352 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Incorrect 55 ms 9052 KB Output isn't correct
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 428 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 436 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 432 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 352 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Incorrect 0 ms 212 KB Output isn't correct
20 Halted 0 ms 0 KB -