# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
284305 |
2020-08-27T08:01:56 Z |
최은수(#5747) |
Aesthetic (NOI20_aesthetic) |
C++17 |
|
615 ms |
63480 KB |
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
ll dis[300010];
vector<pl>adj[300010];
inline void dijk(int n)
{
fill(dis,dis+n+1,INF);
priority_queue<pl,vector<pl>,greater<pl> >pq;
pq.ep(dis[1]=0,1);
while(!pq.empty())
{
int x=pq.top().se;
ll w=pq.top().fi;
pq.pop();
if(dis[x]!=w)
continue;
for(pl&t:adj[x])
if(dis[t.fi]>w+t.se)
pq.ep(dis[t.fi]=w+t.se,t.fi);
}
return;
}
vector<pi>adj2[300010];
int dct;
int disc[300010];
int bmn;
int dfs(int x,int p)
{
int ret=disc[x]=++dct;
for(pi&t:adj2[x])
{
if(t.fi==p)
p=0;
else if(disc[t.fi]==0)
{
int cur=dfs(t.fi,x);
if(cur>disc[x])
bmn=min(bmn,t.se);
ret=min(ret,cur);
}
else
ret=min(ret,disc[t.fi]);
}
return ret;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n,m;
cin>>n>>m;
vector<pair<pi,ll> >edge(m);
for(auto&t:edge)
cin>>t.fi.fi>>t.fi.se>>t.se,
adj[t.fi.fi].eb(t.fi.se,t.se),adj[t.fi.se].eb(t.fi.fi,t.se);
dijk(n);
for(int i=0;i<m;i++)
{
auto&t=edge[i];
if(abs(dis[t.fi.fi]-dis[t.fi.se])==t.se)
adj2[t.fi.fi].eb(t.fi.se,i),adj2[t.fi.se].eb(t.fi.fi,i);
}
bmn=m;
dfs(1,0);
ll mx=0;
for(int i=m-1;i>bmn;i--)
mx=max(mx,edge[i].se);
cout<<dis[n]+mx<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
14464 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
14464 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
613 ms |
48760 KB |
Output is correct |
2 |
Correct |
607 ms |
48928 KB |
Output is correct |
3 |
Correct |
580 ms |
48456 KB |
Output is correct |
4 |
Correct |
585 ms |
48504 KB |
Output is correct |
5 |
Correct |
589 ms |
48524 KB |
Output is correct |
6 |
Correct |
615 ms |
49408 KB |
Output is correct |
7 |
Correct |
606 ms |
49400 KB |
Output is correct |
8 |
Correct |
599 ms |
49656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
598 ms |
49400 KB |
Output is correct |
2 |
Correct |
609 ms |
48888 KB |
Output is correct |
3 |
Correct |
604 ms |
48888 KB |
Output is correct |
4 |
Correct |
602 ms |
49400 KB |
Output is correct |
5 |
Correct |
591 ms |
48636 KB |
Output is correct |
6 |
Correct |
596 ms |
49020 KB |
Output is correct |
7 |
Correct |
606 ms |
49016 KB |
Output is correct |
8 |
Correct |
598 ms |
49016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
545 ms |
49800 KB |
Output is correct |
2 |
Correct |
215 ms |
45176 KB |
Output is correct |
3 |
Correct |
349 ms |
48304 KB |
Output is correct |
4 |
Correct |
355 ms |
52344 KB |
Output is correct |
5 |
Correct |
350 ms |
52344 KB |
Output is correct |
6 |
Correct |
354 ms |
52368 KB |
Output is correct |
7 |
Correct |
356 ms |
52228 KB |
Output is correct |
8 |
Correct |
380 ms |
52600 KB |
Output is correct |
9 |
Correct |
361 ms |
52344 KB |
Output is correct |
10 |
Correct |
369 ms |
52728 KB |
Output is correct |
11 |
Correct |
369 ms |
52472 KB |
Output is correct |
12 |
Correct |
590 ms |
54520 KB |
Output is correct |
13 |
Correct |
358 ms |
52472 KB |
Output is correct |
14 |
Correct |
160 ms |
54156 KB |
Output is correct |
15 |
Correct |
177 ms |
63480 KB |
Output is correct |
16 |
Correct |
566 ms |
54624 KB |
Output is correct |
17 |
Correct |
551 ms |
53364 KB |
Output is correct |
18 |
Correct |
555 ms |
53996 KB |
Output is correct |
19 |
Correct |
218 ms |
49656 KB |
Output is correct |
20 |
Correct |
218 ms |
49656 KB |
Output is correct |
21 |
Correct |
228 ms |
49528 KB |
Output is correct |
22 |
Correct |
222 ms |
49656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
545 ms |
49800 KB |
Output is correct |
2 |
Correct |
215 ms |
45176 KB |
Output is correct |
3 |
Correct |
349 ms |
48304 KB |
Output is correct |
4 |
Correct |
355 ms |
52344 KB |
Output is correct |
5 |
Correct |
350 ms |
52344 KB |
Output is correct |
6 |
Correct |
354 ms |
52368 KB |
Output is correct |
7 |
Correct |
356 ms |
52228 KB |
Output is correct |
8 |
Correct |
380 ms |
52600 KB |
Output is correct |
9 |
Correct |
361 ms |
52344 KB |
Output is correct |
10 |
Correct |
369 ms |
52728 KB |
Output is correct |
11 |
Correct |
369 ms |
52472 KB |
Output is correct |
12 |
Correct |
590 ms |
54520 KB |
Output is correct |
13 |
Correct |
358 ms |
52472 KB |
Output is correct |
14 |
Correct |
160 ms |
54156 KB |
Output is correct |
15 |
Correct |
177 ms |
63480 KB |
Output is correct |
16 |
Correct |
566 ms |
54624 KB |
Output is correct |
17 |
Correct |
551 ms |
53364 KB |
Output is correct |
18 |
Correct |
555 ms |
53996 KB |
Output is correct |
19 |
Correct |
218 ms |
49656 KB |
Output is correct |
20 |
Correct |
218 ms |
49656 KB |
Output is correct |
21 |
Correct |
228 ms |
49528 KB |
Output is correct |
22 |
Correct |
222 ms |
49656 KB |
Output is correct |
23 |
Correct |
547 ms |
50400 KB |
Output is correct |
24 |
Correct |
230 ms |
49784 KB |
Output is correct |
25 |
Incorrect |
290 ms |
44536 KB |
Output isn't correct |
26 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
14464 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |