Submission #284303

# Submission time Handle Problem Language Result Execution time Memory
284303 2020-08-27T07:59:57 Z 최은수(#5747) Aesthetic (NOI20_aesthetic) C++17
22 / 100
667 ms 49704 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=n;
    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 624 ms 48732 KB Output is correct
2 Correct 618 ms 48948 KB Output is correct
3 Correct 633 ms 48400 KB Output is correct
4 Correct 610 ms 48504 KB Output is correct
5 Correct 667 ms 48632 KB Output is correct
6 Correct 651 ms 49460 KB Output is correct
7 Correct 614 ms 49272 KB Output is correct
8 Correct 619 ms 49456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 614 ms 49424 KB Output is correct
2 Correct 600 ms 49016 KB Output is correct
3 Correct 621 ms 48816 KB Output is correct
4 Correct 634 ms 49528 KB Output is correct
5 Correct 610 ms 48764 KB Output is correct
6 Correct 650 ms 48972 KB Output is correct
7 Correct 613 ms 48888 KB Output is correct
8 Correct 603 ms 49272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 524 ms 49704 KB Output is correct
2 Correct 213 ms 45048 KB Output is correct
3 Incorrect 346 ms 48184 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 524 ms 49704 KB Output is correct
2 Correct 213 ms 45048 KB Output is correct
3 Incorrect 346 ms 48184 KB Output isn't correct
4 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 -