# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
140305 |
2019-08-02T13:54:38 Z |
nhc7502 |
None (JOI14_ho_t4) |
C++14 |
|
2000 ms |
15352 KB |
///EVERYONE BELIEVE IN GODTAEGYU
#include<bits/stdc++.h>
using namespace std;
int n, m, i, j, k;
int x, h[100141];
vector<pair<int,int>>graph[100141];
map<pair<int,int>, int>dist;
priority_queue<pair<int,pair<int,int>>>pq;
void f(int tree, int godo, int thist)
{
if(dist.find({tree, godo}) == dist.end())
{
dist[{tree, godo}] = thist;
pq.push({thist, {tree, godo}});
}
else if(dist[{tree, godo}] > thist)
{
dist[{tree, godo}] = thist;
pq.push({thist, {tree, godo}});
}
}
int main(){
iostream::sync_with_stdio(0);cin.tie(0);cout.tie(0);
for(cin>>n>>m>>x; i<n;)
{
cin>>h[++i];
}
for(;m--;)
{
cin>>i>>j>>k;
if(h[i] >= k)
graph[i].push_back({j, k});
if(h[j] >= k)
graph[j].push_back({i, k});
}
dist[{1, x}] = 0;
pq.push({0,{1,x}});
while(!pq.empty())
{
x = pq.top().first;
tie(m, i) = pq.top().second;
pq.pop();
if(dist[{m, i}] != x)
continue;
for(auto next : graph[m])
{ //m = 현재 나무, i = 현재 높이, j = 다음 나무, k = 다음 나무 거리
tie(j, k) = next;
if(i < k) f(j, 0, x + k - i + k);
else if(i - k > h[j]) f(j, h[j], x + i - h[j]);
else f(j, i - k, x + k);
}
if(m == n)
f(n, h[n], x + h[n] - i);
}
if(dist.find({n, h[n]}) == dist.end())
cout<<-1;
else cout<<dist[{n,h[n]}];
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2680 KB |
Output is correct |
2 |
Correct |
150 ms |
2936 KB |
Output is correct |
3 |
Correct |
122 ms |
2896 KB |
Output is correct |
4 |
Correct |
13 ms |
2812 KB |
Output is correct |
5 |
Correct |
47 ms |
2936 KB |
Output is correct |
6 |
Correct |
5 ms |
2680 KB |
Output is correct |
7 |
Correct |
2 ms |
2680 KB |
Output is correct |
8 |
Correct |
152 ms |
2900 KB |
Output is correct |
9 |
Correct |
85 ms |
2936 KB |
Output is correct |
10 |
Correct |
107 ms |
2940 KB |
Output is correct |
11 |
Correct |
4 ms |
2680 KB |
Output is correct |
12 |
Correct |
163 ms |
2900 KB |
Output is correct |
13 |
Correct |
151 ms |
2808 KB |
Output is correct |
14 |
Correct |
22 ms |
2788 KB |
Output is correct |
15 |
Correct |
123 ms |
2936 KB |
Output is correct |
16 |
Correct |
6 ms |
2680 KB |
Output is correct |
17 |
Correct |
5 ms |
2776 KB |
Output is correct |
18 |
Correct |
5 ms |
2808 KB |
Output is correct |
19 |
Correct |
7 ms |
2808 KB |
Output is correct |
20 |
Correct |
6 ms |
2808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2036 ms |
15352 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2680 KB |
Output is correct |
2 |
Correct |
150 ms |
2936 KB |
Output is correct |
3 |
Correct |
122 ms |
2896 KB |
Output is correct |
4 |
Correct |
13 ms |
2812 KB |
Output is correct |
5 |
Correct |
47 ms |
2936 KB |
Output is correct |
6 |
Correct |
5 ms |
2680 KB |
Output is correct |
7 |
Correct |
2 ms |
2680 KB |
Output is correct |
8 |
Correct |
152 ms |
2900 KB |
Output is correct |
9 |
Correct |
85 ms |
2936 KB |
Output is correct |
10 |
Correct |
107 ms |
2940 KB |
Output is correct |
11 |
Correct |
4 ms |
2680 KB |
Output is correct |
12 |
Correct |
163 ms |
2900 KB |
Output is correct |
13 |
Correct |
151 ms |
2808 KB |
Output is correct |
14 |
Correct |
22 ms |
2788 KB |
Output is correct |
15 |
Correct |
123 ms |
2936 KB |
Output is correct |
16 |
Correct |
6 ms |
2680 KB |
Output is correct |
17 |
Correct |
5 ms |
2776 KB |
Output is correct |
18 |
Correct |
5 ms |
2808 KB |
Output is correct |
19 |
Correct |
7 ms |
2808 KB |
Output is correct |
20 |
Correct |
6 ms |
2808 KB |
Output is correct |
21 |
Execution timed out |
2036 ms |
15352 KB |
Time limit exceeded |
22 |
Halted |
0 ms |
0 KB |
- |