Submission #464317

# Submission time Handle Problem Language Result Execution time Memory
464317 2021-08-12T22:13:22 Z nickmet2004 Aesthetic (NOI20_aesthetic) C++11
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 3e5 + 1;
ll n , m , au[N] , av[N] , aw[N];
ll u , v , w , A = 0;
vector<pair<ll, pair<ll , ll> > >  adj[N];
ll d1[N] , dn[N] , f[N] , par[N] , path[N] , son[N];
priority_queue<pair<ll , ll> > pq;
multiset<pair<ll , ll>> S;
vector<ll> B[N] , T[N];
void q(int x){
    f[x] = 1;
    for(auto y : adj[x]){
        //cout << "h";
        auto it = S.find({dn[y.first] + y.second.first + d1[x] , y.second.second});
        if(f[y.first]) S.erase(it);
        else S.insert({dn[x] + y.second.first + d1[y.first] , y.second.second});
    }
}
void dfs(int u , int p){
    if(path[u]) son[u] = u;
    else son[u] = son[p];
    T[son[u]].emplace_back(u);
    for(int v : B[u]) dfs(v , u);
}
main (){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    for(int i  =0; i <m; ++i) cin >> au[i] >> av[i] >> aw[i];
    for(int i = m - 1; ~i; --i){
        u = au[i] , v = av[i] , w= aw[i];
        if( u != v ) {
        adj[u].push_back({v , {w , A}});
        adj[v].push_back({u , {w , A}});
        A = max(A , w);
        }
    }
 
    for(int i = 1; i <= n; ++i) d1[i] = dn[i] = 1e18;
    d1[1] = 0;
    dn[n] = 0;
    pq.push({0 , 1});
    while(pq.size()){
        auto T = pq.top(); pq.pop();
        u = T.second , w = -T.first;
        if(f[u])continue;
        f[u] = 1;
        for(auto e : adj[u]){
            v = e.first;
            if(d1[v] > w + e.second.first){
                par[v] = u;
                d1[v] = w + e.second.first;
                pq.push({-d1[v] , v});
            }
        }
        //cout << "k";
    }
 
    memset(f , 0 ,sizeof(f));
    pq.push({0, n});
    while(pq.size()){
        auto T = pq.top(); pq.pop();
        u = T.second , w = -T.first;
        if(f[u])continue;
        f[u] = 1;
        for(auto e : adj[u]){
            v = e.first;
            if(dn[v] > w + e.second.first){
                dn[v]= w + e.second.first;
                pq.push({-dn[v] , v});
            }
        }
        //cout << "l";
    }
 
    ll X = n;
    while(1){
        path[X] = 1;
        if(X == 1) break;
        X = par[X];
        //cout << "n";
    }
 
    for(int i = 1; i <= n; ++i)B[par[i]].emplace_back(i);
    dfs(1 , 0);
 
    memset(f , 0 ,sizeof(f));
    u = n;
    ll ans = d1[n];
    //cout << "ka";
 
    while(1){
        //cout << "ha";
        if(u == 1)break;
        for(ll v : T[u]) q(v);
        if(!S.size())continue;
        ll k = S.begin()->first + S.begin()->second;
        auto i = S.begin();
        ++i;
        if(i != S.end()) k =min(k , i->first);
        ans = max(ans , k);
        u = par[u];
    }
    cout << ans;
 
}

Compilation message

Aesthetic.cpp:34:2: error: extended character   is not valid in an identifier
   34 |         if( u != v ) {
      |  ^
Aesthetic.cpp:34:5: error: extended character   is not valid in an identifier
   34 |         if( u != v ) {
      |    ^
Aesthetic.cpp:34:8: error: extended character   is not valid in an identifier
   34 |         if( u != v ) {
      |      ^
Aesthetic.cpp:34:11: error: extended character   is not valid in an identifier
   34 |         if( u != v ) {
      |        ^
Aesthetic.cpp:35:2: error: extended character   is not valid in an identifier
   35 |         adj[u].push_back({v , {w , A}});
      |  ^
Aesthetic.cpp:35:5: error: extended character   is not valid in an identifier
   35 |         adj[u].push_back({v , {w , A}});
      |    ^
Aesthetic.cpp:35:8: error: extended character   is not valid in an identifier
   35 |         adj[u].push_back({v , {w , A}});
      |      ^
Aesthetic.cpp:35:11: error: extended character   is not valid in an identifier
   35 |         adj[u].push_back({v , {w , A}});
      |        ^
Aesthetic.cpp:37:2: error: extended character   is not valid in an identifier
   37 |         A = max(A , w);
      |  ^
Aesthetic.cpp:37:5: error: extended character   is not valid in an identifier
   37 |         A = max(A , w);
      |    ^
Aesthetic.cpp:37:8: error: extended character   is not valid in an identifier
   37 |         A = max(A , w);
      |      ^
Aesthetic.cpp:37:11: error: extended character   is not valid in an identifier
   37 |         A = max(A , w);
      |        ^
Aesthetic.cpp:38:2: error: extended character   is not valid in an identifier
   38 |         }
      |  ^
Aesthetic.cpp:38:5: error: extended character   is not valid in an identifier
   38 |         }
      |    ^
Aesthetic.cpp:38:8: error: extended character   is not valid in an identifier
   38 |         }
      |      ^
Aesthetic.cpp:38:11: error: extended character   is not valid in an identifier
   38 |         }
      |        ^
Aesthetic.cpp:39:2: error: extended character   is not valid in an identifier
   39 |     }
      |  ^
Aesthetic.cpp:28:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   28 | main (){
      | ^~~~
Aesthetic.cpp: In function 'int main()':
Aesthetic.cpp:34:2: error: '\U000000a0' was not declared in this scope
   34 |         if( u != v ) {
      |  ^
Aesthetic.cpp:39:4: error: expected ';' before '}' token
   39 |     }
      |   ^ ~
      |   ;