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 <bits/stdc++.h>
#define pii pair<int, int>
#define F first
#define S second
using namespace std;
namespace
{
int N;
bool state;
vector<int> receive, U, V, C;
} // namespace
vector<int> E[2005];
void InitA(int N, int A, vector<int> U, vector<int> V, vector<int> C)
{
::N = N;
::U = U;
::V = V;
::C = C;
SendA(state = U.empty());
}
void ReceiveA(bool x)
{
receive.emplace_back(x);
}
std::vector<int> Answer()
{
vector<int> ans(N);
if (state)
{
for (int i = 0; i < N; i++)
for (int p = 0; p < 20; p++)
ans[i] = ans[i] * 2 + receive[i * 20 + p];
}
else
{
for (int i = 0; i < receive.size() / 32; i++)
{
long long cur = 0;
for (int p = 0; p < 32; p++)
cur = cur * 2 + receive[i * 32 + p];
cerr << i << ' ' << (cur / 500 / 2000) << ' ' << (cur / 500 % 2000) << ' ' << (cur % 500 + 1) << '\n';
U.emplace_back(cur / 500 / 2000);
V.emplace_back(cur / 500 % 2000);
C.emplace_back(cur % 500 + 1);
}
vector<int> dis(N, 1'000'000'000);
vector<pii> E[2000];
dis[0] = 0;
for (int i = 0; i < U.size(); i++)
{
E[U[i]].emplace_back(pii(V[i], C[i]));
E[V[i]].emplace_back(pii(U[i], C[i]));
}
priority_queue<pii, vector<pii>, greater<pii>> pq;
pq.push(pii(0, 0));
while (!pq.empty())
{
auto [d, u] = pq.top();
pq.pop();
if (d > dis[u])
continue;
for (auto [v, w] : E[u])
if (d + w < dis[v])
{
dis[v] = d + w;
pq.push(pii(dis[v], v));
}
}
ans = dis;
}
return ans;
}
#include "Baijan.h"
#include <bits/stdc++.h>
#define pii pair<int, int>
#define F first
#define S second
using namespace std;
namespace
{
int N;
vector<int> receive, S, T, D;
}
void InitB(int N, int B, vector<int> S, vector<int> T, vector<int> D)
{
::N = N;
::S = S;
::T = T;
::D = D;
}
void ReceiveB(bool y)
{
if (y)
{
vector<int> dis(N, 1'000'000'000);
vector<pii> E[2000];
dis[0] = 0;
for (int i = 0; i < S.size(); i++)
{
E[S[i]].emplace_back(pii(T[i], D[i]));
E[T[i]].emplace_back(pii(S[i], D[i]));
}
priority_queue<pii, vector<pii>, greater<pii>> pq;
pq.push(pii(0, 0));
while (!pq.empty())
{
auto [d, u] = pq.top();
pq.pop();
if (d > dis[u])
continue;
for (auto [v, w] : E[u])
if (d + w < dis[v])
{
dis[v] = d + w;
pq.push(pii(dis[v], v));
}
}
for (int i = 0; i < N; i++)
for (int p = 19; p >= 0; p--)
SendB((dis[i] >> p) & 1);
}
else
{
for (int i = 0; i < S.size(); i++)
{
long long cur = S[i] * 2000 * 500 + T[i] * 500 + D[i] - 1;
for (int p = 31; p >= 0; p--)
SendB((cur >> p) & 1);
}
}
}
Compilation message (stderr)
Azer.cpp: In function 'std::vector<int> Answer()':
Azer.cpp:41:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | for (int i = 0; i < receive.size() / 32; i++)
| ~~^~~~~~~~~~~~~~~~~~~~~
Azer.cpp:55:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
55 | for (int i = 0; i < U.size(); i++)
| ~~^~~~~~~~~~
Azer.cpp:64:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
64 | auto [d, u] = pq.top();
| ^
Azer.cpp:68:23: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
68 | for (auto [v, w] : E[u])
| ^
Baijan.cpp: In function 'void ReceiveB(bool)':
Baijan.cpp:29:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | for (int i = 0; i < S.size(); i++)
| ~~^~~~~~~~~~
Baijan.cpp:38:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
38 | auto [d, u] = pq.top();
| ^
Baijan.cpp:42:23: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
42 | for (auto [v, w] : E[u])
| ^
Baijan.cpp:55:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
55 | for (int i = 0; i < S.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... |