# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
678724 |
2023-01-06T13:00:49 Z |
alexdd |
Toll (BOI17_toll) |
C++17 |
|
664 ms |
524288 KB |
#pragma GCC optimize("O3,unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int dim = 2000;
const int INF = 1000000007;
int n,q,k,m;
vector<pair<int,int>> con[50001];
int dist[50001][1+dim];
int query(int st, int dr)
{
if(dr-st<=dim)
return dist[dr][(dr-st)];
int mij=(dr-st)/2;
int mnm=INF;
for(int i=0;i<k;i++)
mnm=min(mnm,query(st,mij+i)+query(mij+i,dr));
return mnm;
}
signed main()
{
ios_base::sync_with_stdio(0);cin.tie(0);
cin>>k>>n>>m>>q;
int a,b,c;
for(int i=0;i<m;i++)
{
cin>>a>>b>>c;
con[b].push_back({a,c});
}
for(int i=0;i<n;i++)
{
///calc dist[i][]
dist[i][0]=0;
for(int j=1;j<=min(i,dim);j++)
{
dist[i][j] = INF;
for(auto adj:con[i])
if(adj.first >= i-j)
dist[i][j]=min(dist[i][j], dist[adj.first][(adj.first - i + j)] + adj.second);
}
}
int rez;
for(int i=0;i<q;i++)
{
cin>>a>>b;
rez=query(a,b);
if(rez>=INF)
rez=-1;
cout<<rez<<"\n";
}
return 0;
}
/**
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
469 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
664 ms |
524288 KB |
Execution killed with signal 9 |
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 |
2 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 |
Correct |
5 ms |
7380 KB |
Output is correct |
7 |
Correct |
7 ms |
7380 KB |
Output is correct |
8 |
Correct |
9 ms |
7448 KB |
Output is correct |
9 |
Correct |
8 ms |
7488 KB |
Output is correct |
10 |
Runtime error |
473 ms |
524288 KB |
Execution killed with signal 9 |
11 |
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 |
2 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 |
Correct |
5 ms |
7380 KB |
Output is correct |
7 |
Correct |
7 ms |
7380 KB |
Output is correct |
8 |
Correct |
9 ms |
7448 KB |
Output is correct |
9 |
Correct |
8 ms |
7488 KB |
Output is correct |
10 |
Runtime error |
473 ms |
524288 KB |
Execution killed with signal 9 |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
469 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |