Submission #583101

# Submission time Handle Problem Language Result Execution time Memory
583101 2022-06-24T20:43:44 Z Johann Two Transportations (JOI19_transportations) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define vvi vector<vi>
#define sz(x) (int) (x).size()
#define all(x) (x).begin(), (x).end()

const int maxn = 20005;
const int LENV = 11;
const int LEND = 8;
int n, maxD = 0;
// int dist[maxn] = { INT_MAX };
vi dist(maxn);
vpii adj[maxn];
int phase;
priority_queue<pii, vpii, greater<pii>> q;


int getMinD() {
    while (!q.empty() && q.top().first >= dist[q.top().second]) q.pop();
    if (q.empty()) return ((1 << LEND) - 1);
    return q.top().first - maxD;
}
int getMinV() { return (!q.empty()) ? q.top().second : -1; }
// may call SendA()
void send(int m, int len) {
    for (int i = 0; i < len; ++i) {
        SendA(m & 1);
        m = m >> 1;
    }
}
// Variables for ...
int d,cntD=0; // receiving distances
int v,cntV=0; // receiving points
int cntN=0; // counting the

void addVertexWithDist(int vv, int dd) {
    dist[vv] = dd;
    maxD = dd;

    ++cntN;
    if (cntN == n) return;

    int u,c;
    for (pii e : adj[vv]) {
        tie(u,c) = e;
        q.push({ dist[vv] + c, u });
    }

    send(getMinD(), LEND);
    phase = LEND;
    d = 0;
}
void receiveD(bool x) {
    d = (d << 1) + x;
    ++cntD;
    if (cntD == LEND) {
        cntD = 0;
        if (d < getMinD()) { // Aufpassen mit < und <= in der anderen Datei.
            phase = LENV;
            v = 0;
            // rest folgt in receive V
        } else {
            int vv = getMinV();
            int dd = maxD + getMinD();
            q.pop();
            send(v, LENV);
            addVertexWithDist(vv, dd); // starts new iteration
        }
    }
}
void receiveV(bool x) {
    v = (v << 1) + x;
    ++cntV;
    if (cntV == LENV) {
        cntV = 0;
        addVertexWithDist(v, maxD + d);
    }
}
void ReceiveA(bool x) {
    if (phase == LEND) { // Distance
        receiveD(x);
    } else { // Knoten
        receiveV(x);
    }
}
void InitA(int N, int A, vi U, vi V, vi C) {
    n = N;
    dist.resize(n);
    for (int i = 0; i < A; ++i) {
        adj[U[i]].push_back({ V[i], C[i] });
        adj[V[i]].push_back({ U[i], C[i] });
    }
    addVertexWithDist(0, 0);
}
vi Answer() {
    return dist;
}
#include <bits/stdc++.h>
using namespace std;

#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define vvi vector<vi>
#define sz(x) (int) (x).size()
#define all(x) (x).begin(), (x).end()

const int maxn = 20005;
const int LENV = 11;
const int LEND = 8;
int n, maxD = 0;
// int dist[maxn] = { INT_MAX };
vi dist(maxn);
vpii adj[maxn];
int phase;
priority_queue<pii, vpii, greater<pii>> q;


int getMinD() {
    while (!q.empty() && q.top().first >= dist[q.top().second]) q.pop();
    if (q.empty()) return ((1 << LEND) - 1);
    return q.top().first - maxD;
}
int getMinV() { return (!q.empty()) ? q.top().second : -1; }
// may call SendB()
void send(int m, int len) {
    for (int i = 0; i < len; ++i) {
        SendB(m & 1);
        m = m >> 1;
    }
}
// Variables for ...
int d,cntD=0; // receiving distances
int v,cntV=0; // receiving points
int cntN=0; // counting the

void addVertexWithDist(int vv, int dd) {
    dist[vv] = dd;
    maxD = dd;

    ++cntN;
    if (cntN == n) return;

    int u,c;
    for (pii e : adj[vv]) {
        tie(u,c) = e;
        q.push({ dist[vv] + c, u });
    }

    send(getMinD(), LEND);
    phase = LEND;
    d = 0;
}
void receiveD(bool x) {
    d = (d << 1) + x;
    ++cntD;
    if (cntD == LEND) {
        cntD = 0;
        if (d < getMinD()) { // Aufpassen mit < und <= in der anderen Datei.
            phase = LENV;
            v = 0;
            // rest folgt in receive V
        } else {
            int vv = getMinV();
            int dd = maxD + getMinD();
            q.pop();
            send(v, LENV);
            addVertexWithDist(vv, dd); // starts new iteration
        }
    }
}
void receiveV(bool x) {
    v = (v << 1) + x;
    ++cntV;
    if (cntV == LENV) {
        cntV = 0;
        addVertexWithDist(v, maxD + d);
    }
}
void ReceiveB(bool x) {
    if (phase == LEND) { // Distance
        receiveD(x);
    } else { // Knoten
        receiveV(x);
    }
}
void InitB(int N, int A, vi U, vi V, vi C) {
    n = N;
    dist.resize(n);
    for (int i = 0; i < A; ++i) {
        adj[U[i]].push_back({ V[i], C[i] });
        adj[V[i]].push_back({ U[i], C[i] });
    }
    addVertexWithDist(0, 0);
}

Compilation message

Azer.cpp: In function 'void send(int, int)':
Azer.cpp:31:9: error: 'SendA' was not declared in this scope
   31 |         SendA(m & 1);
      |         ^~~~~

Baijan.cpp: In function 'void send(int, int)':
Baijan.cpp:31:9: error: 'SendB' was not declared in this scope
   31 |         SendB(m & 1);
      |         ^~~~~