Submission #285103

# Submission time Handle Problem Language Result Execution time Memory
285103 2020-08-28T10:18:27 Z toloraia Aesthetic (NOI20_aesthetic) C++14
22 / 100
490 ms 48888 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long
#define int long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")

#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")

#pragma comment(linker, "/STACK: 20000000005")
*/

using namespace std;

const int N = 300005, INF = 5e14;

int n, m;
int u[N], v[N], x[N], y[N];
int dp[N][2];
bool F[N][2];

vector < pair < int, pair < int, int > > > G[N];

priority_queue < pair < int, pair < int, int > > > Q;

main()
{
    //freopen ("in.in", "r", stdin);freopen ("out.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin >> n >> m;
    for (int i = 1; i <= m; i++){
        cin >> u[i] >> v[i] >> x[i];
    }
    for (int i = m; i >= 1; i--){
        y[i] = max (x[i+1], y[i+1]);
        G[u[i]].pb ({v[i], {x[i], y[i]}});
        G[v[i]].pb ({u[i], {x[i], y[i]}});
    }
    for (int i = 2; i <= n; i++)
        dp[i][0] = dp[i][1] = INF;
    dp[1][0] = 0;
    dp[1][1] = 0;
    Q.push ({0, {1, 0}});
    Q.push ({0, {1, 1}});
    while (Q.size() > 0){
        int k = Q.top().S.F, ch = Q.top().S.S, D;
        Q.pop();
        if (F[k][ch])
            continue;
        F[k][ch] = 1;
        for (auto it : G[k]){
            int to = it.F;
            if (ch == 0){
                D = dp[k][0] + it.S.F;
                if (D < dp[to][0]){
                    dp[to][0] = D;
                    Q.push ({-D, {to, 0}});
                }
            }
            else {
                D = it.S.F + max (dp[k][0] + it.S.S, dp[k][1]);
                if (D < dp[to][1]){
                    dp[to][1] = D;
                    Q.push ({-D, {to, 1}});
                }
            }
        }
    }
    cout << dp[n][1] << endl;
}

Compilation message

Aesthetic.cpp:18: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
   18 | #pragma GCC optimization ("unroll-loops")
      | 
Aesthetic.cpp:44:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   44 | main()
      |      ^
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 7424 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 7424 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 455 ms 46508 KB Output is correct
2 Correct 451 ms 48248 KB Output is correct
3 Correct 485 ms 47736 KB Output is correct
4 Correct 468 ms 47736 KB Output is correct
5 Correct 471 ms 47864 KB Output is correct
6 Correct 490 ms 48760 KB Output is correct
7 Correct 458 ms 48536 KB Output is correct
8 Correct 465 ms 48888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 457 ms 47020 KB Output is correct
2 Correct 460 ms 48216 KB Output is correct
3 Correct 476 ms 48088 KB Output is correct
4 Correct 470 ms 48888 KB Output is correct
5 Correct 454 ms 48248 KB Output is correct
6 Correct 441 ms 48120 KB Output is correct
7 Correct 458 ms 48320 KB Output is correct
8 Correct 452 ms 48376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 442 ms 47080 KB Output is correct
2 Correct 198 ms 44536 KB Output is correct
3 Incorrect 223 ms 44024 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 442 ms 47080 KB Output is correct
2 Correct 198 ms 44536 KB Output is correct
3 Incorrect 223 ms 44024 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 7424 KB Output isn't correct
2 Halted 0 ms 0 KB -