#include "shortcut.h"
//#include "grader.cpp"
#include<bits/stdc++.h>
using namespace std;
long long M[501][501],Q[501],VIS[501];
vector<vector<pair<int,int>>>edges(501);
long long DIJK(int Node){
for(int i=0;i<501;i++)
VIS[i]=-1;
priority_queue<pair<long long,int>>lol;
lol.push({-Q[Node],Node});
while(lol.size()){
long long F=-lol.top().first;
int S=lol.top().second;
lol.pop();
if(VIS[S]+1)
continue;
VIS[S]=F+Q[S];
for(int i=0;i<edges[S].size();i++){
lol.push({-(edges[S][i].second+F),edges[S][i].first});
}
}
long long maxer=0;
for(int i=0;i<501;i++)
maxer=max(maxer,VIS[i]);
return maxer;
}
long long find_shortcut(int n,vector<int>l,vector<int>d,int c)
{
for(int i=0;i<n;i++)
Q[i]=d[i];
for(int i=0;i<n-1;i++)
edges[i].push_back({i+1,l[i]}),edges[i+1].push_back({i,l[i]});
for(int i=0;i<n;i++){
for(int l=i+1;l<n;l++){
long long MAXER=0;
edges[i].push_back({l,c});
edges[l].push_back({i,c});
for(int x=0;x<n;x++){
MAXER=max(MAXER,DIJK(x));
M[i][l]=MAXER;
}
edges[i].pop_back(),edges[l].pop_back();
}
}
long long miner=(long long)4e18;
for(int i=0;i<n;i++){
for(int l=i+1;l<n;l++){
miner=min(miner,M[i][l]);
}
}
return miner;
}
Compilation message
shortcut.cpp: In function 'long long int DIJK(int)':
shortcut.cpp:19:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
19 | for(int i=0;i<edges[S].size();i++){
| ~^~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
332 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
332 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
1 ms |
204 KB |
n = 3, 4 is a correct answer |
5 |
Incorrect |
1 ms |
204 KB |
n = 2, incorrect answer: jury 62 vs contestant 72 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
332 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
332 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
1 ms |
204 KB |
n = 3, 4 is a correct answer |
5 |
Incorrect |
1 ms |
204 KB |
n = 2, incorrect answer: jury 62 vs contestant 72 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
332 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
332 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
1 ms |
204 KB |
n = 3, 4 is a correct answer |
5 |
Incorrect |
1 ms |
204 KB |
n = 2, incorrect answer: jury 62 vs contestant 72 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
332 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
332 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
1 ms |
204 KB |
n = 3, 4 is a correct answer |
5 |
Incorrect |
1 ms |
204 KB |
n = 2, incorrect answer: jury 62 vs contestant 72 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
332 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
332 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
1 ms |
204 KB |
n = 3, 4 is a correct answer |
5 |
Incorrect |
1 ms |
204 KB |
n = 2, incorrect answer: jury 62 vs contestant 72 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
332 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
332 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
1 ms |
204 KB |
n = 3, 4 is a correct answer |
5 |
Incorrect |
1 ms |
204 KB |
n = 2, incorrect answer: jury 62 vs contestant 72 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
332 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
332 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
1 ms |
204 KB |
n = 3, 4 is a correct answer |
5 |
Incorrect |
1 ms |
204 KB |
n = 2, incorrect answer: jury 62 vs contestant 72 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
n = 4, 80 is a correct answer |
2 |
Correct |
1 ms |
332 KB |
n = 9, 110 is a correct answer |
3 |
Correct |
1 ms |
332 KB |
n = 4, 21 is a correct answer |
4 |
Correct |
1 ms |
204 KB |
n = 3, 4 is a correct answer |
5 |
Incorrect |
1 ms |
204 KB |
n = 2, incorrect answer: jury 62 vs contestant 72 |
6 |
Halted |
0 ms |
0 KB |
- |