Submission #135576

# Submission time Handle Problem Language Result Execution time Memory
135576 2019-07-24T08:29:08 Z E869120 Two Transportations (JOI19_transportations) C++14
0 / 100
1930 ms 2840 KB
#include "Azer.h"
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
using namespace std;

const int BIT2_A = 12;

int NA, distA[2009];
vector<pair<int, int>> XA[2009];
map<pair<int, int>, int> ForcedA;

void pushesA(int pos, int val) {
	// 最初の 11 ビットは頂点、次の 20 ビットはコスト
	for (int i = 0; i < 11; i++) SendA((bool)((pos / (1 << i)) % 2));
	for (int i = 0; i < BIT2_A; i++) SendA((bool)((val / (1 << i)) % 2));
}

void InitA(int N, int A, std::vector<int> U, std::vector<int> V, std::vector<int> C) {
	NA = N;
	for (int i = 0; i < U.size(); i++) {
		XA[U[i]].push_back(make_pair(V[i], C[i]));
		XA[V[i]].push_back(make_pair(U[i], C[i]));
	}
	for (int i = 0; i < N; i++) distA[i] = (1 << 20) - 1;
	distA[0] = 0; ForcedA[make_pair(0, 0)] = 1;
	pushesA(0, (1 << (BIT2_A - 1)));
	for (int i = 0; i < XA[0].size(); i++) distA[XA[0][i].first] = XA[0][i].second;
}

int countA = 0, VA = 0, LA = 0;
int CurrentTimeA = 0;

void ReceiveA(bool x) {
	if (countA < 11 + BIT2_A) {
		if (x == true) VA += (1 << countA);
		countA++;
	}
	if (countA == 11 + BIT2_A) {
		int pos = (VA & 2047), val = (VA >> 11); if (val != (1 << BIT2_A) - 1) CurrentTimeA += (val - (1 << (BIT2_A - 1)));
		if (pos != 2047) {
			if (distA[pos] > CurrentTimeA) {
				if (val != (1 << BIT2_A) - 1) distA[pos] = CurrentTimeA;
				if (val != (1 << BIT2_A) - 1) ForcedA[make_pair(distA[pos], pos)] = 1;
				for (int i = 0; i < XA[pos].size(); i++) {
					int to = XA[pos][i].first, cost = XA[pos][i].second;
					if (distA[to] > distA[pos] + cost) {
						distA[to] = distA[pos] + cost;
					}
				}
			}
		}

		pair<int, int> minid = make_pair(1 << 30, -1);
		for (int i = 0; i < NA; i++) {
			if (ForcedA[make_pair(distA[i], i)] == 0) minid = min(minid, make_pair(distA[i], i));
		}

		if (minid.second != -1) {
			if (minid.first != 1048575) {
				ForcedA[minid] = 1;
				if (abs(minid.first - CurrentTimeA) >= (1 << (BIT2_A - 1)) - 1) {
					minid.first += 0;
				}
				pushesA(minid.second, minid.first - CurrentTimeA + (1 << (BIT2_A - 1)));
				CurrentTimeA = minid.first;
			}
			else {
				pushesA(minid.second, (1 << BIT2_A) - 1);
			}

			for (int i = 0; i < XA[minid.second].size(); i++) {
				int to = XA[minid.second][i].first, cost = XA[minid.second][i].second;
				if (distA[to] > minid.first + cost) {
					distA[to] = minid.first + cost;
				}
			}
		}
		else if (pos != 2047) {
			pushesA(2047, (1 << BIT2_A) - 1);
		}
	}
	if (countA == 11 + BIT2_A) { countA = 0; VA = 0; }
}

vector<int> Answer() {
	vector<int>E;
	for (int i = 0; i < NA; i++) E.push_back(distA[i]);
	return E;
}
#include "Baijan.h"
#include <vector>
#include <queue>
#include <functional>
#include <algorithm>
#include <map>
using namespace std;

const int BIT2_B = 12;

int NB, distB[2009];
vector<pair<int, int>> XB[2009];
map<pair<int, int>, int> ForcedB;
bool usedB[2009];

void pushesB(int pos, int val) {
	// 最初の 11 ビットは頂点、次の 20 ビットはコスト
	for (int i = 0; i < 11; i++) SendB((bool)((pos / (1 << i)) % 2));
	for (int i = 0; i < BIT2_B; i++) SendB((bool)((val / (1 << i)) % 2));
}

void InitB(int N, int B, vector<int> S, vector<int> T, vector<int> D) {
	NB = N;
	for (int i = 0; i < S.size(); i++) {
		XB[S[i]].push_back(make_pair(T[i], D[i]));
		XB[T[i]].push_back(make_pair(S[i], D[i]));
	}
	for (int i = 0; i < N; i++) distB[i] = (1 << 20) - 1;
	distB[0] = 0;
	for (int i = 0; i < XB[0].size(); i++) distB[XB[0][i].first] = XB[0][i].second;
	ForcedB[make_pair(0, 0)] = 1;
}

int countB = 0, VB = 0;
int CurrentTimeB = 0;

void ReceiveB(bool y) {
	if (countB < 11 + BIT2_B) {
		if (y == true) VB += (1 << countB);
		countB++;
	}
	if (countB == 11 + BIT2_B) {
		int pos = (VB & 2047), val = (VB >> 11); if (val != (1 << BIT2_B) - 1) CurrentTimeB += (val - (1 << (BIT2_B - 1)));
		if (pos != 2047) {
			if (distB[pos] > CurrentTimeB) {
				if (val != (1 << BIT2_B) - 1) distB[pos] = CurrentTimeB;
				if (val != (1 << BIT2_B) - 1) ForcedB[make_pair(distB[pos], pos)] = 1;
				for (int i = 0; i < XB[pos].size(); i++) {
					int to = XB[pos][i].first, cost = XB[pos][i].second;
					if (distB[to] > distB[pos] + cost) {
						distB[to] = distB[pos] + cost;
					}
				}
			}
		}

		pair<int, int> minid = make_pair(1 << 30, -1);
		for (int i = 0; i < NB; i++) {
			if (ForcedB[make_pair(distB[i], i)] == 0) minid = min(minid, make_pair(distB[i], i));
		}

		if (minid.second != -1) {
			if (minid.first != 1048575) {
				ForcedB[minid] = 1;
				if (abs(minid.first - CurrentTimeB) >= (1 << (BIT2_B - 1)) - 1) {
					minid.first += 0;
				}
				pushesB(minid.second, minid.first - CurrentTimeB + (1 << (BIT2_B - 1)));
				CurrentTimeB = minid.first;
			}
			else {
				pushesB(minid.second, (1 << BIT2_B) - 1);
			}

			for (int i = 0; i < XB[minid.second].size(); i++) {
				int to = XB[minid.second][i].first, cost = XB[minid.second][i].second;
				if (distB[to] > minid.first + cost) {
					distB[to] = minid.first + cost;
				}
			}
		}
		else if (pos != 2047) {
			pushesB(2047, (1 << BIT2_B) - 1);
		}
	}
	if (countB == 11 + BIT2_B) { countB = 0; VB = 0; }
}

Compilation message

Azer.cpp: In function 'void InitA(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
Azer.cpp:23:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < U.size(); i++) {
                  ~~^~~~~~~~~~
Azer.cpp:30:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < XA[0].size(); i++) distA[XA[0][i].first] = XA[0][i].second;
                  ~~^~~~~~~~~~~~~~
Azer.cpp: In function 'void ReceiveA(bool)':
Azer.cpp:47:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < XA[pos].size(); i++) {
                     ~~^~~~~~~~~~~~~~~~
Azer.cpp:74:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (int i = 0; i < XA[minid.second].size(); i++) {
                    ~~^~~~~~~~~~~~~~~~~~~~~~~~~

Baijan.cpp: In function 'void InitB(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
Baijan.cpp:24:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < S.size(); i++) {
                  ~~^~~~~~~~~~
Baijan.cpp:30:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < XB[0].size(); i++) distB[XB[0][i].first] = XB[0][i].second;
                  ~~^~~~~~~~~~~~~~
Baijan.cpp: In function 'void ReceiveB(bool)':
Baijan.cpp:48:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < XB[pos].size(); i++) {
                     ~~^~~~~~~~~~~~~~~~
Baijan.cpp:75:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (int i = 0; i < XB[minid.second].size(); i++) {
                    ~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1047 ms 1236 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1088 KB Output is correct
2 Correct 1918 ms 2672 KB Output is correct
3 Incorrect 1002 ms 1392 KB Wrong Answer [2]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1930 ms 2840 KB Output is correct
2 Correct 6 ms 992 KB Output is correct
3 Incorrect 1004 ms 1196 KB Wrong Answer [2]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 579 ms 2176 KB Output is correct
2 Incorrect 902 ms 2136 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 579 ms 2176 KB Output is correct
2 Incorrect 902 ms 2136 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 579 ms 2176 KB Output is correct
2 Incorrect 902 ms 2136 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1047 ms 1236 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -