답안 #284299

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
284299 2020-08-27T07:58:01 Z 최은수(#5747) Aesthetic (NOI20_aesthetic) C++17
22 / 100
681 ms 56188 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>t.fi)
                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;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 14464 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 14464 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 601 ms 50168 KB Output is correct
2 Correct 637 ms 50360 KB Output is correct
3 Correct 611 ms 49912 KB Output is correct
4 Correct 617 ms 49768 KB Output is correct
5 Correct 631 ms 50040 KB Output is correct
6 Correct 637 ms 50800 KB Output is correct
7 Correct 631 ms 50552 KB Output is correct
8 Correct 640 ms 50808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 634 ms 50808 KB Output is correct
2 Correct 598 ms 55544 KB Output is correct
3 Correct 591 ms 55416 KB Output is correct
4 Correct 681 ms 56188 KB Output is correct
5 Correct 589 ms 55216 KB Output is correct
6 Correct 638 ms 55556 KB Output is correct
7 Correct 612 ms 55408 KB Output is correct
8 Correct 607 ms 55672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 582 ms 51276 KB Output is correct
2 Correct 228 ms 49440 KB Output is correct
3 Incorrect 370 ms 50936 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 582 ms 51276 KB Output is correct
2 Correct 228 ms 49440 KB Output is correct
3 Incorrect 370 ms 50936 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 14464 KB Output isn't correct
2 Halted 0 ms 0 KB -