# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
472224 |
2021-09-13T09:48:44 Z |
morasha3 |
Toll (BOI17_toll) |
C++17 |
|
3000 ms |
5648 KB |
#include<bits/stdc++.h>
typedef long long ll;
const ll mod = (ll) 1e9 + 7;
const ll mx = (ll) 1e5 +7;
using namespace std;
vector<vector<pair<ll,ll>>>v(50007);
ll k,n,q,m,ans=0;
void dfs(ll idx,ll cnt,ll e)
{
if(idx==e)
{
ans=min(cnt,ans);
return;
}
for(int i=0;i<v[idx].size();i++)
{
dfs(v[idx][i].first,cnt+v[idx][i].second,e);
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>k>>n>>m>>q;
for(int i=0;i<m;i++)
{
ll a,b,c;
cin>>a>>b>>c;
v[a].push_back({b,c});
}
for(int i=0;i<q;i++)
{
ll a,b;
ans=INT_MAX;
cin>>a>>b;
dfs(a,0,b);
if(ans==INT_MAX)ans=-1;
cout<<ans<<endl;
}
}
Compilation message
toll.cpp: In function 'void dfs(ll, ll, ll)':
toll.cpp:16:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
16 | for(int i=0;i<v[idx].size();i++)
| ~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3095 ms |
5648 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3095 ms |
4728 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1484 KB |
Output is correct |
2 |
Correct |
1 ms |
1484 KB |
Output is correct |
3 |
Correct |
1 ms |
1484 KB |
Output is correct |
4 |
Correct |
1 ms |
1484 KB |
Output is correct |
5 |
Correct |
1 ms |
1484 KB |
Output is correct |
6 |
Correct |
2 ms |
1516 KB |
Output is correct |
7 |
Execution timed out |
3085 ms |
1556 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1484 KB |
Output is correct |
2 |
Correct |
1 ms |
1484 KB |
Output is correct |
3 |
Correct |
1 ms |
1484 KB |
Output is correct |
4 |
Correct |
1 ms |
1484 KB |
Output is correct |
5 |
Correct |
1 ms |
1484 KB |
Output is correct |
6 |
Correct |
2 ms |
1516 KB |
Output is correct |
7 |
Execution timed out |
3085 ms |
1556 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3095 ms |
5648 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |