# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
498656 |
2021-12-26T04:44:39 Z |
model_code |
Paths (RMI21_paths) |
C++17 |
|
600 ms |
23980 KB |
// paths_subtask2_alexandra.cpp
//N^2 * K^2
#include<iostream>
#include<vector>
#include<cstring>
#include<stdlib.h>
#include<time.h>
using namespace std;
int n, i, x, y, c, k;
long long d[1005][1005];
vector< pair<int, int> > v[1005];
void dfs(int nod, int t) {
for (int i = 0; i < v[nod].size(); i++) {
int fiu = v[nod][i].first;
if (fiu == t) {
continue;
}
dfs(fiu, nod);
for (int j = k; j >= 1; j--) {
d[nod][j] = max(d[nod][j], d[nod][j - 1] + v[nod][i].second);
for (int jj = 1; jj <= j; jj++) {
d[nod][j] = max(d[nod][j], d[nod][j - jj] + d[fiu][jj] + v[nod][i].second);
}
}
}
}
int main() {
cin>> n >> k;
for (i = 1; i < n; i++) {
cin>> x >> y >> c;
v[x].push_back(make_pair(y, c));
v[y].push_back(make_pair(x, c));
}
for (i = 1; i <= n; i++) {
memset(d, 0, sizeof(d));
dfs(i, 0);
cout<< d[i][k] <<"\n";
}
}
Compilation message
Main.cpp: In function 'void dfs(int, int)':
Main.cpp:14:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
14 | for (int i = 0; i < v[nod].size(); i++) {
| ~~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
8140 KB |
Output is correct |
2 |
Correct |
14 ms |
8224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
8140 KB |
Output is correct |
2 |
Correct |
14 ms |
8224 KB |
Output is correct |
3 |
Correct |
187 ms |
8212 KB |
Output is correct |
4 |
Correct |
173 ms |
8140 KB |
Output is correct |
5 |
Correct |
185 ms |
8212 KB |
Output is correct |
6 |
Correct |
169 ms |
8212 KB |
Output is correct |
7 |
Correct |
165 ms |
8140 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
8140 KB |
Output is correct |
2 |
Correct |
14 ms |
8224 KB |
Output is correct |
3 |
Correct |
187 ms |
8212 KB |
Output is correct |
4 |
Correct |
173 ms |
8140 KB |
Output is correct |
5 |
Correct |
185 ms |
8212 KB |
Output is correct |
6 |
Correct |
169 ms |
8212 KB |
Output is correct |
7 |
Correct |
165 ms |
8140 KB |
Output is correct |
8 |
Execution timed out |
1063 ms |
8144 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
8140 KB |
Output is correct |
2 |
Correct |
14 ms |
8224 KB |
Output is correct |
3 |
Correct |
187 ms |
8212 KB |
Output is correct |
4 |
Correct |
173 ms |
8140 KB |
Output is correct |
5 |
Correct |
185 ms |
8212 KB |
Output is correct |
6 |
Correct |
169 ms |
8212 KB |
Output is correct |
7 |
Correct |
165 ms |
8140 KB |
Output is correct |
8 |
Execution timed out |
1063 ms |
8144 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
162 ms |
23980 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
8140 KB |
Output is correct |
2 |
Correct |
14 ms |
8224 KB |
Output is correct |
3 |
Correct |
187 ms |
8212 KB |
Output is correct |
4 |
Correct |
173 ms |
8140 KB |
Output is correct |
5 |
Correct |
185 ms |
8212 KB |
Output is correct |
6 |
Correct |
169 ms |
8212 KB |
Output is correct |
7 |
Correct |
165 ms |
8140 KB |
Output is correct |
8 |
Execution timed out |
1063 ms |
8144 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |