# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1042376 | 2024-08-03T03:07:47 Z | baldwinhuang1 | Shortcut (IOI16_shortcut) | C++14 | 1 ms | 348 KB |
#include <bits/stdc++.h> using namespace std; vector< vector<int> > nodes; vector< vector<int> > weights; const long long INF = 1e18; long long dist[1000][1000] ;// Voy a hacer subtask 1, el 1000 es para estar seguro void floydWarshall(int n) { int i, j, k; for (int i = 0; i < (n); i++) { for (int j = 0; j < (n + n); j++) { dist[i][j] = INF; } } for (int i = 0; i < (n); i++) { for (int j = 0; j < (n); j++) { if (i == j) { dist[i][j] = 0; } else if (nodes[i][j] == true) { dist[i][j] = min(dist[i][j], (long long)weights[i][j]); } } } for (k = 0; k < (n); k++) { for (i = 0; i < (n); i++) { for (j = 0; j < (n); j++) { if (dist[i][j] > (dist[i][k] + dist[k][j]) && (dist[k][j] != INF && dist[i][k] != INF)) dist[i][j] = dist[i][k] + dist[k][j]; } } } } long long find_shortcut(int n, vector <int> l, vector <int> d, int c) { for (auto &i: d) { if (i != 0) { n++; } } nodes = vector< vector<int> >(n, vector<int>(n)); weights = vector< vector<int> >(n, vector<int>(n)); // cout << n << '\n'; for (int i = 0; i < l.size(); i++) { // cout << i << '\n'; nodes[i][i + 1] = true; nodes[i + 1][i] = true; weights[i][i + 1] = l[i]; weights[i + 1][i] = l[i]; } int j = l.size() + 1; for (int i = 0; i < d.size(); i++) { if (d[i] != 0) { // cout << i << ' ' << j << '\n'; nodes[i][j] = true; nodes[j][i] = true; weights[i][j] = d[i]; weights[j][i] = d[i]; j++; } } floydWarshall(n); // for (int i = 0; i < (n); i++) { // for (int j = 0; j < (n); j++) { // cout << dist[i][j] << ' '; // } // cout << '\n'; // } long long minimo = 1e18; for (int i = 0; i < (n - 1); i++) { for (int j = (i + 1); j < n; j++) { if (i != j && i <= l.size() && j <= l.size()) { // cout << "############" << '\n'; int node1 = nodes[i][j]; int node2 = nodes[j][i]; int weight1 = weights[i][j]; int weight2 = weights[j][i]; nodes[i][j] = true; nodes[j][i] = true; weights[i][j] = c; weights[j][i] = c; floydWarshall(n); long long ans = 0; for (int i = 0; i < (n); i++) { for (int j = 0; j < (n); j++) { ans = max(ans, dist[i][j]); } } // cout << ans << ' ' << i << ' ' << j << '\n'; minimo = min(ans, minimo); nodes[i][j] = node1; nodes[j][i] = node2; weights[i][j] = weight1; weights[j][i] = weight2; } } } return minimo; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | n = 4, 80 is a correct answer |
2 | Correct | 1 ms | 348 KB | n = 9, 110 is a correct answer |
3 | Correct | 0 ms | 348 KB | n = 4, 21 is a correct answer |
4 | Correct | 0 ms | 348 KB | n = 3, 4 is a correct answer |
5 | Correct | 0 ms | 348 KB | n = 2, 62 is a correct answer |
6 | Incorrect | 0 ms | 348 KB | n = 2, incorrect answer: jury 3 vs contestant 4 |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | n = 4, 80 is a correct answer |
2 | Correct | 1 ms | 348 KB | n = 9, 110 is a correct answer |
3 | Correct | 0 ms | 348 KB | n = 4, 21 is a correct answer |
4 | Correct | 0 ms | 348 KB | n = 3, 4 is a correct answer |
5 | Correct | 0 ms | 348 KB | n = 2, 62 is a correct answer |
6 | Incorrect | 0 ms | 348 KB | n = 2, incorrect answer: jury 3 vs contestant 4 |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | n = 4, 80 is a correct answer |
2 | Correct | 1 ms | 348 KB | n = 9, 110 is a correct answer |
3 | Correct | 0 ms | 348 KB | n = 4, 21 is a correct answer |
4 | Correct | 0 ms | 348 KB | n = 3, 4 is a correct answer |
5 | Correct | 0 ms | 348 KB | n = 2, 62 is a correct answer |
6 | Incorrect | 0 ms | 348 KB | n = 2, incorrect answer: jury 3 vs contestant 4 |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | n = 4, 80 is a correct answer |
2 | Correct | 1 ms | 348 KB | n = 9, 110 is a correct answer |
3 | Correct | 0 ms | 348 KB | n = 4, 21 is a correct answer |
4 | Correct | 0 ms | 348 KB | n = 3, 4 is a correct answer |
5 | Correct | 0 ms | 348 KB | n = 2, 62 is a correct answer |
6 | Incorrect | 0 ms | 348 KB | n = 2, incorrect answer: jury 3 vs contestant 4 |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | n = 4, 80 is a correct answer |
2 | Correct | 1 ms | 348 KB | n = 9, 110 is a correct answer |
3 | Correct | 0 ms | 348 KB | n = 4, 21 is a correct answer |
4 | Correct | 0 ms | 348 KB | n = 3, 4 is a correct answer |
5 | Correct | 0 ms | 348 KB | n = 2, 62 is a correct answer |
6 | Incorrect | 0 ms | 348 KB | n = 2, incorrect answer: jury 3 vs contestant 4 |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | n = 4, 80 is a correct answer |
2 | Correct | 1 ms | 348 KB | n = 9, 110 is a correct answer |
3 | Correct | 0 ms | 348 KB | n = 4, 21 is a correct answer |
4 | Correct | 0 ms | 348 KB | n = 3, 4 is a correct answer |
5 | Correct | 0 ms | 348 KB | n = 2, 62 is a correct answer |
6 | Incorrect | 0 ms | 348 KB | n = 2, incorrect answer: jury 3 vs contestant 4 |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | n = 4, 80 is a correct answer |
2 | Correct | 1 ms | 348 KB | n = 9, 110 is a correct answer |
3 | Correct | 0 ms | 348 KB | n = 4, 21 is a correct answer |
4 | Correct | 0 ms | 348 KB | n = 3, 4 is a correct answer |
5 | Correct | 0 ms | 348 KB | n = 2, 62 is a correct answer |
6 | Incorrect | 0 ms | 348 KB | n = 2, incorrect answer: jury 3 vs contestant 4 |
7 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | n = 4, 80 is a correct answer |
2 | Correct | 1 ms | 348 KB | n = 9, 110 is a correct answer |
3 | Correct | 0 ms | 348 KB | n = 4, 21 is a correct answer |
4 | Correct | 0 ms | 348 KB | n = 3, 4 is a correct answer |
5 | Correct | 0 ms | 348 KB | n = 2, 62 is a correct answer |
6 | Incorrect | 0 ms | 348 KB | n = 2, incorrect answer: jury 3 vs contestant 4 |
7 | Halted | 0 ms | 0 KB | - |