Submission #266518

# Submission time Handle Problem Language Result Execution time Memory
266518 2020-08-15T10:37:47 Z dolphingarlic Two Transportations (JOI19_transportations) C++14
0 / 100
559 ms 1536 KB
#include "Azer.h"

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

namespace {
int N, stage = 0, cnt;
vector<pair<int, int>> graph[2000];
vector<int> known, shortest;
bool visited[2000];
pair<int, int> candidate = {0, 0};

void reset() {
    known.push_back(candidate.second);
    visited[candidate.second] = true;
    shortest[candidate.second] = candidate.first;

    if (known.size() == N) return;
    candidate = {10000000, -1};
    for (int i : known) {
        for (pair<int, int> j : graph[i]) if (!visited[j.first]) {
            candidate = min(candidate, {shortest[i] + j.second, j.first});
        }
    }
    for (int i = 0; i < 20; i++) SendA((candidate.first & (1 << i)) >> i);
    cnt = stage = 0;
}
}  // namespace

void InitA(int N, int A, vector<int> U, vector<int> V, vector<int> C) {
    ::N = N;
    shortest.resize(N);
    for (int i = 0; i < A; i++) {
        graph[U[i]].push_back({V[i], C[i]});
        graph[V[i]].push_back({U[i], C[i]});
    }
    reset();
}

void ReceiveA(bool x) {
    if (stage == 0) {
        if (x) {
            stage++;
            candidate = {0, 0};
        } else {
            for (int i = 0; i < 11; i++) SendA((candidate.first & (1 << i)) >> i);
            reset();
        }
    } else if (stage == 1) {
        candidate.first |= x << cnt++;
        if (cnt == 20) {
            stage++;
            cnt = 0;
        }
    } else {
        candidate.second |= x << cnt++;
        if (cnt == 11) reset();
    }
}

vector<int> Answer() {
    return shortest;
}
#include "Baijan.h"

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

namespace {
int N, stage = 0, cnt, a_shortest;
vector<pair<int, int>> graph[2000];
vector<int> known, shortest;
bool visited[2000];
pair<int, int> candidate = {0, 0};

void reset() {
    known.push_back(candidate.second);
    visited[candidate.second] = true;
    shortest[candidate.second] = candidate.first;

    candidate = {10000000, -1};
    for (int i : known) {
        for (pair<int, int> j : graph[i]) if (!visited[j.first]) {
            candidate = min(candidate, {shortest[i] + j.second, j.first});
        }
    }
    cnt = stage = a_shortest = 0;
}
}  // namespace

void InitB(int N, int B, vector<int> S, vector<int> T, vector<int> D) {
    ::N = N;
    shortest.resize(N);
    for (int i = 0; i < B; i++) {
        graph[S[i]].push_back({T[i], D[i]});
        graph[T[i]].push_back({S[i], D[i]});
    }
    reset();
}

void ReceiveB(bool y) {
    if (stage == 0) {
        a_shortest |= y << cnt++;
        if (cnt == 20) {
            if (a_shortest > candidate.first) {
                SendB(1);
                for (int i = 0; i < 20; i++) SendB((candidate.first & (1 << i)) >> i);
                for (int i = 0; i < 11; i++) SendB((candidate.second & (1 << i)) >> i);
                reset();
            } else {
                SendB(0);
                cnt = 0;
                candidate = {a_shortest, 0};
                stage++;
            }
        }
    } else if (stage == 1) {
        candidate.second |= y << cnt++;
        if (cnt == 11) reset();
    }
}

Compilation message

Azer.cpp: In function 'void {anonymous}::reset()':
Azer.cpp:18:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   18 |     if (known.size() == N) return;
      |         ~~~~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 497 ms 1008 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1536 KB Output is correct
2 Runtime error 559 ms 1172 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 43 ms 1008 KB Unexpected end of file - int32 expected (Baijan)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 77 ms 1056 KB Unexpected end of file - int32 expected (Baijan)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 77 ms 1056 KB Unexpected end of file - int32 expected (Baijan)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 77 ms 1056 KB Unexpected end of file - int32 expected (Baijan)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 497 ms 1008 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -