QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#122574#67. Two Transportationsjrjyy0 3ms4040kbC++204.6kb2023-07-10 19:25:202023-08-20 01:30:44

Judging History

你现在查看的是最新测评结果

  • [2023-08-20 01:30:44]
  • 管理员手动重测该提交记录
  • 测评结果:0
  • 用时:3ms
  • 内存:4040kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-10 19:25:32]
  • 评测
  • 测评结果:0
  • 用时:4ms
  • 内存:3932kb
  • [2023-07-10 19:25:20]
  • 提交

Azer

#include "Azer.h"

namespace {
void send(bool x) { SendA(x); }
}
#include <bits/stdc++.h>

namespace {
void send(bool x);
constexpr int inf = 1e6, LgN = 11, LgW = 9;

bool first; int n, cnt; std::vector<int> dis, vs;
std::vector<std::vector<std::pair<int, int>>> adj;
void addEdge(int u, int v, int w) { adj[u].push_back({v, w}); }
std::priority_queue<std::pair<int, int>> h;

void init(bool f, int n_, int m, std::vector<int> U, std::vector<int> V, std::vector<int> W) {
    first = f, n = n_, adj.resize(n), dis.resize(n, inf), dis[0] = 0, h.push({0, 0}), vs.resize(n);
    for (int i = 0; i < m; ++i) addEdge(U[i], V[i], W[i]), addEdge(V[i], U[i], W[i]);
}

std::deque<bool> msg;
int getMsg(int len) {
    int x = 0;
    while (len--) x = x << 1 | msg.front(), msg.pop_front();
    return x;
}
void setMsg(int x, int len) {
    x = std::min(x, (1 << len) - 1);
    while (len--) send(x >> len & 1);
}

int lst, typ, nd;
void query() {
    typ = 0;
    while (!h.empty() && vs[h.top().second]) h.pop();
    setMsg(h.empty() ? inf : -h.top().first - lst, LgW);
    // std::cerr << "BA"[first] << " Send: " << (h.empty() ? inf : -h.top().first - lst) << '\n';
}
void relax(int u) {
    vs[u] = 1, ++cnt;
    // std::cerr << "BA"[first] << " Relax: " << u << " = " << dis[u] << ' ' << cnt << '\n';
    for (auto p : adj[u]) {
        int v = p.first, w = p.second;
        if (dis[v] > dis[u] + w) dis[v] = dis[u] + w, h.push({-dis[v], v});
    }
}
void receive(bool x) {
    msg.push_back(x);
    // std::cerr << "BA"[first] << " Recv " << x << '\n';
    if (typ == 0) {
        if (int(msg.size()) != LgW) return;
        nd = getMsg(LgW) + lst;
        if (-h.top().first - first < nd) {
            int u = h.top().second; h.pop();
            relax(u), setMsg(u, LgN);
            if (cnt < n) query();
        } else {
            typ = 1;
        }
    } else {
        if (int(msg.size()) != LgN) return;
        int u = getMsg(LgN);
        dis[u] = nd, relax(u);
        if (cnt < n) query();
    }
}

std::vector<int> answer() { return dis; }
}

void InitA(int n, int m, std::vector <int> U, std::vector <int> V, std::vector <int> W) {
    ::init(true, n, m, U, V, W), ::query();
}

void ReceiveA(bool x) { ::receive(x); }
std::vector<int> Answer() { return ::answer(); }

Baijan

#include "Baijan.h"

namespace {
void send(bool x) { SendB(x); }
}

#include <bits/stdc++.h>

namespace {
void send(bool x);
constexpr int inf = 1e6, LgN = 11, LgW = 9;

bool first; int n, cnt; std::vector<int> dis, vs;
std::vector<std::vector<std::pair<int, int>>> adj;
void addEdge(int u, int v, int w) { adj[u].push_back({v, w}); }
std::priority_queue<std::pair<int, int>> h;

void init(bool f, int n_, int m, std::vector<int> U, std::vector<int> V, std::vector<int> W) {
    first = f, n = n_, adj.resize(n), dis.resize(n, inf), dis[0] = 0, h.push({0, 0}), vs.resize(n);
    for (int i = 0; i < m; ++i) addEdge(U[i], V[i], W[i]), addEdge(V[i], U[i], W[i]);
}

std::deque<bool> msg;
int getMsg(int len) {
    int x = 0;
    while (len--) x = x << 1 | msg.front(), msg.pop_front();
    return x;
}
void setMsg(int x, int len) {
    x = std::min(x, (1 << len) - 1);
    while (len--) send(x >> len & 1);
}

int lst, typ, nd;
void query() {
    typ = 0;
    while (!h.empty() && vs[h.top().second]) h.pop();
    setMsg(h.empty() ? inf : -h.top().first - lst, LgW);
    // std::cerr << "BA"[first] << " Send: " << (h.empty() ? inf : -h.top().first - lst) << '\n';
}
void relax(int u) {
    vs[u] = 1, ++cnt;
    // std::cerr << "BA"[first] << " Relax: " << u << " = " << dis[u] << ' ' << cnt << '\n';
    for (auto p : adj[u]) {
        int v = p.first, w = p.second;
        if (dis[v] > dis[u] + w) dis[v] = dis[u] + w, h.push({-dis[v], v});
    }
}
void receive(bool x) {
    msg.push_back(x);
    // std::cerr << "BA"[first] << " Recv " << x << '\n';
    if (typ == 0) {
        if (int(msg.size()) != LgW) return;
        nd = getMsg(LgW) + lst;
        if (-h.top().first - first < nd) {
            int u = h.top().second; h.pop();
            relax(u), setMsg(u, LgN);
            if (cnt < n) query();
        } else {
            typ = 1;
        }
    } else {
        if (int(msg.size()) != LgN) return;
        int u = getMsg(LgN);
        dis[u] = nd, relax(u);
        if (cnt < n) query();
    }
}

std::vector<int> answer() { return dis; }
}

void InitB(int n, int m, std::vector <int> U, std::vector <int> V, std::vector <int> W) {
    ::init(false, n, m, U, V, W), ::query();
}

void ReceiveB(bool x) { ::receive(x); }

详细

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

score: 0
Time Limit Exceeded

input:

0 0 0 0 0 0 0 0 0 -1
0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 -1

output:

-1
0 0 0 0 0 0 0 0 0 -1
0 1 0 1 1 0 1 0 0 0 0 1 1 0 0 1 0 1 0 0 1 0 1 0 0 0 0 1 1 -1

input:


output:


result:

wrong answer 1st lines differ - expected: '0', found: ''

Subtask #2:

score: 0
Time Limit Exceeded

Test #7:

score: 8
Accepted
time: 0ms
memory: 3720kb

input:

0 0 0 0 0 0 0 0 0 -1
0 0 0 0 0 0 0 0 0 0 0 -1
-1

output:

-1
0 0 0 0 0 0 0 0 0 -1
-1
-1

input:


output:

0

result:

ok single line: '0'

Test #8:

score: 0
Time Limit Exceeded

input:

0 0 0 0 0 0 0 0 0 -1
0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 -1

output:

-1
0 0 0 0 0 0 0 0 0 -1
0 1 1 0 1 0 1 0 1 0 0 1 0 0 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 -1

input:


output:


result:

wrong answer 1st lines differ - expected: '0', found: ''

Subtask #3:

score: 0
Wrong Answer

Test #14:

score: 0
Wrong Answer
time: 3ms
memory: 3864kb

input:

0 0 0 0 0 0 0 0 0 -1
0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 1 1 0 0 1 -1
0 0 0 0 1 1 1 0 0 1 1 1 0 0 1 1 1 0 1 1 -1
0 1 1 0 0 1 0 0 1 1 1 1 1 0 0 0 1 0 0 0 -1
0 0 0 0 0 0 1 0 0 1 1 1 1 1 1 1 1 1 1 1 -1
1 1 1 1 1 1 1 1 1 -1
-1

output:

-1
0 0 0 0 0 0 0 0 0 -1
1 1 0 1 0 0 1 0 1 -1
1 1 0 1 0 0 1 0 1 -1
1 1 0 1 0 0 1 0 1 -1
1 1 0 1 0 0 1 0 1 0 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 -1
-1
-1

input:


output:

0
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
392
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
100000...

result:

wrong answer 2nd lines differ - expected: '3328', found: '1000000'

Subtask #4:

score: 0
Time Limit Exceeded

Test #24:

score: 0
Time Limit Exceeded

input:

0 0 0 0 0 0 0 0 0 -1
0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 -1

output:

-1
0 0 0 0 0 0 0 0 0 -1
0 1 0 0 1 0 0 1 1 0 0 1 1 0 0 1 0 0 0 1 1 1 0 0 0 0 0 0 1 -1

input:


output:


result:

wrong answer 1st lines differ - expected: '0', found: ''

Subtask #5:

score: 0
Time Limit Exceeded

Test #38:

score: 0
Time Limit Exceeded

input:

0 0 0 0 0 0 0 0 0 -1
0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 0 -1

output:

-1
0 0 0 0 0 0 0 0 0 -1

input:


output:


result:

wrong answer 1st lines differ - expected: '0', found: ''

Subtask #6:

score: 0
Time Limit Exceeded

Test #51:

score: 0
Time Limit Exceeded

input:

0 0 0 0 0 0 0 0 0 -1
0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 -1

output:

-1
0 0 0 0 0 0 0 0 0 -1
0 1 0 1 1 0 0 0 0 0 1 0 1 0 1 1 1 1 0 1 1 1 1 1 1 1 0 1 0 -1

input:


output:


result:

wrong answer 1st lines differ - expected: '0', found: ''

Subtask #7:

score: 0
Wrong Answer

Test #64:

score: 0
Wrong Answer
time: 0ms
memory: 4040kb

input:

0 0 0 0 0 0 0 0 0 -1
0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 -1
1 0 0 0 1 1 1 0 1 0 0 1 1 1 1 1 1 1 1 1 -1
-1
-1

output:

-1
0 0 0 0 0 0 0 0 0 -1
1 1 1 1 1 0 0 1 1 -1
1 1 1 1 1 1 1 1 1 -1
-1

input:


output:

0
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
10...

result:

wrong answer 2nd lines differ - expected: '25855', found: '1000000'