Submission #242452

# Submission time Handle Problem Language Result Execution time Memory
242452 2020-06-27T17:50:44 Z SorahISA Olympic Bus (JOI20_ho_t4) C++17
0 / 100
50 ms 4712 KB
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(1, 1E8); \
                 auto rnd = bind(__dis, __gen)

const int INF = 1E18;
const int mod = 1E9 + 7;
const int maxn = 200 + 5;

struct Edge {
    int u, v, c, d;
    Edge(int _u = 0, int _v = 0, int _c = 0, int _d = 0) :
        u(_u), v(_v), c(_c), d(_d) {}
};

vector<Edge> edge;
int floyd[maxn][maxn];

void init() {
    for (int i = 0; i < maxn; ++i) {
        for (int j = 0; j < maxn; ++j) floyd[i][j] = INF;
        floyd[i][i] = 0;
    }
}

int32_t main() {
    fastIO();
    init();
    
    int n, m;
    cin >> n >> m;
    
    for (int i = 0; i < m; ++i) {
        int u, v, c, d;
        cin >> u >> v >> c >> d;
        edge.eb(u, v, c, d);
        floyd[u][v] = min(floyd[u][v], c);
    }
    
    for (int mid = 1; mid <= n; ++mid) {
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= n; ++j) {
                floyd[i][j] = min(floyd[i][j], floyd[i][mid] + floyd[mid][j]);
            }
        }
    }
    
    /* if (floyd[1][n] != INF and floyd[n][1] == INF) {
        int minC = INF;
        for (auto e : edge) {
            // if (floyd[e.u][1] != INF and floyd[n][e.v] != INF) //
            minC = min(minC, floyd[e.u][1] + floyd[n][e.v] + e.c + e.d);
        }
        cout << (minC == INF ? -1 : minC + floyd[1][n]) << "\n";
        return 0;
    } */
    
    int minC = floyd[1][n] + floyd[n][1];
    for (auto e : edge) {
        int min1N = min(floyd[1][n], floyd[e.u][n] + floyd[1][e.v] + e.c);
        int minN1 = min(floyd[n][1], floyd[e.u][1] + floyd[n][e.v] + e.c);
        cout << min1N << " " << minN1 << " " << e.d << " " << min1N + minN1 + e.d << "\n";
        minC = min(minC, min1N + minN1 + e.d);
    }
    
    cout << (minC >= INF ? -1 : minC) << "\n";
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 896 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 50 ms 4712 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 768 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 896 KB Output isn't correct
2 Halted 0 ms 0 KB -