# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
714849 |
2023-03-25T10:50:58 Z |
ajab_01 |
Toll (BOI17_toll) |
C++17 |
|
3000 ms |
51944 KB |
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 9;
const int N = 5e4 + 5;
const int SQ = 250;
vector<pair<int , int> > g[N];
int dp[N][SQ] , dis[N] , k , n , m , o , a , b;
int main(){
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> k >> n >> m >> o;
for(int i = 0 ; i < m ; i++){
int u , v , w;
cin >> u >> v >> w;
g[v].push_back({u , w});
}
for(int i = 0 ; i < n ; i++){
for(int d = 1 ; d < min(n - i , SQ) ; d++){
int v = i + d;
dp[i][d] = INF;
for(pair<int , int> p : g[v]){
int u = p.first , w = p.second;
if(u < i) continue;
dp[i][d] = min(dp[i][d] , dp[i][u - i] + w);
}
}
}
for(int oo = 0 ; oo < o ; oo++){
cin >> a >> b;
int vala = a / k , valb = b / k;
fill(dis + vala * k , dis + (vala + 1) * k , INF);
dis[a] = 0;
while(valb - vala >= 69 + 85 + 1){
fill(dis + (vala + 69 + 85) * k , dis + (vala + 69 + 85 + 1) * k , INF);
for(int i = (vala + 69 + 85) * k ; i < (vala + 69 + 85 + 1) * k ; i++) for(int j = vala * k ; j < (vala + 1) * k ; j++) dis[i] = min(dis[i] , dis[j] + dp[j][i - j]);
}
dis[b] = INF;
for(int i = vala * k ; i < (vala + 1) * k ; i++) dis[b] = min(dis[b] , dis[i] + dp[i][b - i]);
(dis[b] == INF ? cout << -1 << '\n' : cout << dis[b] << '\n');
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3074 ms |
51852 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3069 ms |
51944 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1492 KB |
Output is correct |
2 |
Correct |
1 ms |
1492 KB |
Output is correct |
3 |
Correct |
1 ms |
1492 KB |
Output is correct |
4 |
Correct |
1 ms |
1492 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Execution timed out |
3046 ms |
2516 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1492 KB |
Output is correct |
2 |
Correct |
1 ms |
1492 KB |
Output is correct |
3 |
Correct |
1 ms |
1492 KB |
Output is correct |
4 |
Correct |
1 ms |
1492 KB |
Output is correct |
5 |
Correct |
1 ms |
1492 KB |
Output is correct |
6 |
Execution timed out |
3046 ms |
2516 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3074 ms |
51852 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |