This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "Azer.h"
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
using namespace std;
int NA, distA[2009]; bool usedA[2009];
vector<pair<int, int>> XA[2009];
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 < 20; 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 << 30);
distA[0] = 0; usedA[0] = true;
pushesA(0, 0);
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;
void ReceiveA(bool x) {
if (countA < 31) {
if (x == true) VA += (1 << countA);
countA++;
}
if (countA == 31) {
int pos = (VA & 1023), val = (VA >> 11);
if (distA[pos] > val) {
distA[pos] = val;
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 (usedA[i] == false) minid = min(minid, make_pair(distA[i], i));
}
if (minid.second != -1) {
pushesA(minid.second, minid.first); if (val >= minid.first) usedA[minid.second] = true;
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;
}
}
}
}
if (countA == 31) { 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>
using namespace std;
int NB, distB[2009]; bool usedB[2009];
vector<pair<int, int>> XB[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 < 20; 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 << 30);
distB[0] = 0;
for (int i = 0; i < XB[0].size(); i++) distB[XB[0][i].first] = XB[0][i].second;
}
int countB = 0, VB = 0;
void ReceiveB(bool y) {
if (countB < 31) {
if (y == true) VB += (1 << countB);
countB++;
}
if (countB == 31) {
int pos = (VB & 1023), val = (VB >> 11);
if (distB[pos] > val) {
distB[pos] = val;
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 (usedB[i] == false) minid = min(minid, make_pair(distB[i], i));
}
if (minid.second != -1) {
pushesB(minid.second, minid.first); if (val >= minid.first) usedB[minid.second] = true;
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;
}
}
}
}
if (countB == 31) { countB = 0; VB = 0; }
}
Compilation message (stderr)
Azer.cpp: In function 'void InitA(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
Azer.cpp:19:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < U.size(); i++) {
~~^~~~~~~~~~
Azer.cpp:26: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:40:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < XA[pos].size(); i++) {
~~^~~~~~~~~~~~~~~~
Azer.cpp:54: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:19:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < S.size(); i++) {
~~^~~~~~~~~~
Baijan.cpp:25: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:39:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < XB[pos].size(); i++) {
~~^~~~~~~~~~~~~~~~
Baijan.cpp:54: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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |