Submission #673703

# Submission time Handle Problem Language Result Execution time Memory
673703 2022-12-21T18:41:54 Z rainboy Two Transportations (JOI19_transportations) C++17
6 / 100
570 ms 36904 KB
#include "Azer.h"
#include <cstring>
#include <vector>

using namespace std;

typedef vector<int> vi;

const int N = 2000;

namespace A {
	const int INF = 0x3f3f3f3f;
	int ww[N][N], dd[N], n, n1, d_, s, k, z; char used[N];
	void relax(int i, long long d) {
		dd[i] = d, used[i] = 1;
		for (int j = 0; j < n; j++)
			if (!used[j])
				dd[j] = min(dd[j], dd[i] + ww[i][j]);
	}
	int nxt() {
		int i_ = -1;
		for (int i = 0; i < n; i++)
			if (!used[i] && dd[i] != INF && (i_ == -1 || dd[i_] > dd[i]))
				i_ = i;
		return i_;
	}
}

void InitA(int n_, int m, vi ii, vi jj, vi ww_) {
	A::n = n_, A::n1 = 0;
	for (int i = 0; i < A::n; i++)
		memset(A::ww[i], 0x3f, A::n * sizeof *A::ww[i]);
	for (int h = 0; h < m; h++) {
		int i = ii[h], j = jj[h], w = ww_[h];
		A::ww[i][j] = A::ww[j][i] = w;
	}
	memset(A::dd, 0x3f, A::n * sizeof *A::dd), A::dd[0] = A::d_ = 0;
	A::s = 0, A::k = 0, A::z = 0;
	for (int l = 0; l < 9; l++)
		SendA((A::dd[0] - A::d_) >> l & 1);
	for (int l = 0; l < 11; l++)
		SendA(0 >> l & 1);
	A::relax(0, 0);
}

void ReceiveA(bool x) {
	if (x)
		A::z |= 1 << A::k;
	A::k++;
	if (A::k != (A::s == 0 ? 9 : 20))
		return;
	if (A::s == 1 && A::k == 20) {
		int i = A::z >> 9;
		A::relax(i, A::d_);
		A::z &= (1 << 9) - 1;
	}
	if (++A::n1 == A::n)
		return;
	int i = A::nxt(), d = i == -1 ? (1 << 9) - 1 : A::dd[i] - A::d_;
	for (int l = 0; l < 9; l++)
		SendA(d >> l & 1);
	if (d <= A::z) {
		A::s = 0;
		for (int l = 0; l < 11; l++)
			SendA(i >> l & 1);
		A::relax(i, A::d_ += d);
	} else {
		A::s = 1;
		A::d_ += A::z;
	}
	A::k = 0, A::z = 0;
}

vi Answer() {
	return vi(A::dd, A::dd + A::n);
}
#include "Baijan.h"
#include <cstring>
#include <vector>

using namespace std;

typedef vector<int> vi;

const int N = 2000;

namespace B {
	const int INF = 0x3f3f3f3f;
	int ww[N][N], dd[N], n, n1, d_, k, z; char used[N];
	void relax(int i, long long d) {
		dd[i] = d, used[i] = 1;
		for (int j = 0; j < n; j++)
			if (!used[j])
				dd[j] = min(dd[j], dd[i] + ww[i][j]);
	}
	int nxt() {
		int i_ = -1;
		for (int i = 0; i < n; i++)
			if (!used[i] && dd[i] != INF && (i_ == -1 || dd[i_] > dd[i]))
				i_ = i;
		return i_;
	}
}

void InitB(int n_, int m, vi ii, vi jj, vi ww_) {
	B::n = n_;
	for (int i = 0; i < B::n; i++)
		memset(B::ww[i], 0x3f, B::n * sizeof *B::ww[i]);
	for (int h = 0; h < m; h++) {
		int i = ii[h], j = jj[h], w = ww_[h];
		B::ww[i][j] = B::ww[j][i] = w;
	}
	memset(B::dd, 0x3f, B::n * sizeof *B::dd), B::dd[0] = B::d_ = 0;
	B::k = 0, B::z = 0;
}

void ReceiveB(bool y) {
	if (y)
		B::z |= 1 << B::k;
	B::k++;
	if (B::k == 9) {
		int i = B::nxt();
		if (i != -1 && B::d_ + B::z > B::dd[i]) {
			B::relax(i, B::d_ = B::dd[i]);
			int j = B::nxt(), d = j == -1 ? (1 << 9) - 1 : B::dd[j] - B::d_;
			for (int l = 0; l < 9; l++)
				SendB(d >> l & 1);
			for (int l = 0; l < 11; l++)
				SendB(i >> l & 1);
			B::k = 0, B::z = 0;
		}
	} else if (B::k == 20) {
		int i = B::z >> 9, j, d = B::z & (1 << 9) - 1;
		B::relax(i, B::d_ = d);
		j = B::nxt(), d = j == -1 ? (1 << 9) - 1 : B::dd[j] - B::d_;
		for (int l = 0; l < 9; l++)
			SendB(d >> l & 1);
		B::k = 0, B::z = 0;
	}
}

Compilation message

Baijan.cpp: In function 'void ReceiveB(bool)':
Baijan.cpp:57:45: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   57 |   int i = B::z >> 9, j, d = B::z & (1 << 9) - 1;
      |                                    ~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 515 ms 31880 KB Output is correct
2 Correct 1 ms 400 KB Output is correct
3 Correct 546 ms 31888 KB Output is correct
4 Correct 570 ms 36904 KB Output is correct
5 Correct 26 ms 1424 KB Output is correct
6 Correct 435 ms 32460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 400 KB Output is correct
2 Correct 530 ms 31840 KB Output is correct
3 Incorrect 54 ms 31940 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 31880 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 13968 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 13968 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 13968 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 515 ms 31880 KB Output is correct
2 Correct 1 ms 400 KB Output is correct
3 Correct 546 ms 31888 KB Output is correct
4 Correct 570 ms 36904 KB Output is correct
5 Correct 26 ms 1424 KB Output is correct
6 Correct 435 ms 32460 KB Output is correct
7 Correct 1 ms 400 KB Output is correct
8 Correct 530 ms 31840 KB Output is correct
9 Incorrect 54 ms 31940 KB Output isn't correct
10 Halted 0 ms 0 KB -