Submission #565102

# Submission time Handle Problem Language Result Execution time Memory
565102 2022-05-20T09:34:37 Z maomao90 Two Transportations (JOI19_transportations) C++17
8 / 100
463 ms 36812 KB
// Hallelujah, praise the one who set me free
// Hallelujah, death has lost its grip on me
// You have broken every chain, There's salvation in your name
// Jesus Christ, my living hope
#include <bits/stdc++.h> 
#include "Azer.h"
using namespace std;

template <class T>
inline bool mnto(T& a, T b) {return a > b ? a = b, 1 : 0;}
template <class T>
inline bool mxto(T& a, T b) {return a < b ? a = b, 1: 0;}
#define REP(i, s, e) for (int i = s; i < e; i++)
#define RREP(i, s, e) for (int i = s; i >= e; i--)
typedef long long ll;
typedef long double ld;
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> iii;
#define ALL(_a) _a.begin(), _a.end()
#define pb push_back
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<iii> viii;

#ifndef DEBUG
#define cerr if (0) cerr
#endif

const int INF = 1000000005;
const ll LINF = 1000000000000000005ll;
const int MAXN = 200005;

namespace {
    const int NLOG = 11, CLOG = 9;
    int n, m;
    vii adj[MAXN];
    queue<bool> qu;
    int vis[MAXN];

    iii get() {
        int u = 0, v = 0, c = 0;
        REP (i, 0, NLOG) {
            u += qu.front() << i;
            qu.pop();
        }
        REP (i, 0, NLOG) {
            v += qu.front() << i;
            qu.pop();
        }
        REP (i, 0, CLOG) {
            c += qu.front() << i;
            qu.pop();
        }
        return {u, v, c};
    }
}

void InitA(int N, int A, vi U, vi V, vi C) {
    n = N; m = A;
    REP (i, 0, m) {
        adj[U[i]].pb({V[i], C[i]});
        adj[V[i]].pb({U[i], C[i]});
    }
}

void ReceiveA(bool x) {
    qu.push(x);
    if (qu.size() == NLOG * 2 + CLOG) {
        auto [u, v, c] = get();
        cerr << u << ' ' << v << ' ' << c << '\n';
        adj[u].pb({v, c});
        adj[v].pb({u, c});
    }
}

vi Answer() {
    vi dist(n, INF);
    dist[0] = 0;
    while (1) {
        int u = -1, d = INF;
        REP (i, 0, n) {
            if (vis[i]) continue;
            if (mnto(d, dist[i])) {
                u = i;
            }
        }
        if (u == -1) {
            break;
        }
        vis[u] = 1;
        for (auto [v, w] : adj[u]) {
            mnto(dist[v], d + w);
        }
    }
    return dist;
}
// Hallelujah, praise the one who set me free
// Hallelujah, death has lost its grip on me
// You have broken every chain, There's salvation in your name
// Jesus Christ, my living hope
#include <bits/stdc++.h> 
#include "Baijan.h"
using namespace std;

template <class T>
inline bool mnto(T& a, T b) {return a > b ? a = b, 1 : 0;}
template <class T>
inline bool mxto(T& a, T b) {return a < b ? a = b, 1: 0;}
#define REP(i, s, e) for (int i = s; i < e; i++)
#define RREP(i, s, e) for (int i = s; i >= e; i--)
typedef long long ll;
typedef long double ld;
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> iii;
#define ALL(_a) _a.begin(), _a.end()
#define pb push_back
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<iii> viii;

#ifndef DEBUG
#define cerr if (0) cerr
#endif

const int INF = 1000000005;
const ll LINF = 1000000000000000005ll;
const int MAXN = 200005;

namespace {
    const int NLOG = 11, CLOG = 9;
    int n, m;
    vii adj[MAXN];

    void send(int u, int v, int c) {
        REP (i, 0, NLOG) {
            SendB(u >> i & 1);
        }
        REP (i, 0, NLOG) {
            SendB(v >> i & 1);
        }
        REP (i, 0, CLOG) {
            SendB(c >> i & 1);
        }
    }
}

void InitB(int N, int B, vi U, vi V, vi C) {
    n = N; m = B;
    REP (i, 0, m) {
        adj[U[i]].pb({V[i], C[i]});
        adj[V[i]].pb({U[i], C[i]});
    }
    REP (u, 0, n) {
        for (auto [v, c] : adj[u]) {
            if (v < u) continue;
            send(u, v, c);
        }
    }
}

void ReceiveB(bool y) {
}
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 4936 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 9872 KB Output is correct
2 Correct 277 ms 10132 KB Output is correct
3 Correct 260 ms 10208 KB Output is correct
4 Correct 325 ms 36812 KB Output is correct
5 Correct 188 ms 33556 KB Output is correct
6 Correct 167 ms 10124 KB Output is correct
7 Correct 463 ms 33608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 265 ms 10112 KB Output is correct
2 Correct 7 ms 9872 KB Output is correct
3 Runtime error 4 ms 4996 KB Execution killed with signal 13
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 78 ms 10172 KB Output is correct
2 Correct 255 ms 10076 KB Output is correct
3 Runtime error 34 ms 11328 KB Execution killed with signal 13
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 78 ms 10172 KB Output is correct
2 Correct 255 ms 10076 KB Output is correct
3 Runtime error 34 ms 11328 KB Execution killed with signal 13
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 78 ms 10172 KB Output is correct
2 Correct 255 ms 10076 KB Output is correct
3 Runtime error 34 ms 11328 KB Execution killed with signal 13
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 4936 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -