#include<bits/stdc++.h>
using namespace std;
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>pq;
int stan=9,akbit,czyt,czyt2,liczbaodwiedzonych=1,n,last;
int odwiedzone[2137 + 1];
vector<pair<int, int>> sasiedzi[2000];
vector<int>answer;
void sendInt(int a,int rozmiar){
vector<bool>v;
for(int i=0;i<rozmiar;i++){
v.push_back(a%2);
a/=2;
}
for(int i=rozmiar-1;i>=0;i++){
SendA(v[i]);
}
}
void InitA(int N, int A, vector<int>U, vector<int>V, vector<int>C) {
odwiedzone[0] = 1;
n = N;
for (int i = 1; i < N; i++) {
answer.push_back(9999999);
for (int i = 0; i < A; i++) {
sasiedzi[U[i]].push_back({ C[i],V[i] });
sasiedzi[V[i]].push_back({ C[i],U[i] });
}
for (int i = 0; i < (int)sasiedzi1[0].size(); i++) {
pq.push(sasiedzi[0][i]);
}
sendInt(pq.top().first,9);
}
void ReceiveA(bool y){
if(stan == 9){
czyt*=2;
czyt+=y;
akbit++;
if(akbit==9){
if(liczbaodwiedzonych==n)
return;
liczbaodwiedzonych++;
while(!pq.empty() && odwiedzone[pq.top().second])
pq.pop();
if(pq.empty())
pq.push({510,2137});
if(pq.top().first-last>czyt){
odwiedzone[pq.top().second] = 1;
answer[pq.top().second] = pq.top().first.first;
for (int i = 0; i < (int)sasiedzi[pq.top().second].size(); i++) {
pq.push({ sasiedzi[pq.top().second][i].first + pq.top().first + last,sasiedzi[pq.top().second][i].second });
}
last+ = pq.top().first;
czyt=0;
sendInt(pq.top().second,11);
pq.pop();
while(!pq.empty() && odwiedzone[pq.top().second])
pq.pop();
if(pq.empty())
pq.push({510,2137});
sendInt(pq.top().first-last,9);
}
else{
stan=11;
}
akbit=0;
}
}
if(stan==11){
czyt2*=2;
czyt2+=y;
akbit++;
if(akbit==11){
akbit=0;
answer[czyt2]=czyt+last;
for (int i = 0; i < (int)sasiedzi[czyt2].size(); i++) {
pq.push({ sasiedzi[czyt2][i].first + czyt + last,sasiedzi[pq.top().second][i].second });
}
czyt=0;
czyt2=0;
while(!pq.empty() && odwiedzone[pq.top().second])
pq.pop();
if(pq.empty())
pq.push({510,2137});
sendInt(pq.top().first-last-czyt,9);
last+=czyt;
}
}
}
vector<int>Answer(){
return answer;
}
#include<bits/stdc++.h>
using namespace std;
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>pq;
int stan=9,akbit,czyt,czyt2,liczbaodwiedzonych=1,n,last;
int odwiedzone[2137 + 1];
vector<pair<int, int>> sasiedzi[2000];
vector<int>answer;
void sendInt(int a,int rozmiar){
vector<bool>v;
for(int i=0;i<rozmiar;i++){
v.push_back(a%2);
a/=2;
}
for(int i=rozmiar-1;i>=0;i++){
SendB(v[i]);
}
}
void InitB(int N, int B, vector<int>U, vector<int>V, vector<int>C) {
odwiedzone[0] = 1;
n = N;
for (int i = 1; i < N; i++) {
answer.push_back(9999999);
for (int i = 0; i < A; i++) {
sasiedzi[U[i]].push_back({ C[i],V[i] });
sasiedzi[V[i]].push_back({ C[i],U[i] });
}
for (int i = 0; i < (int)sasiedzi1[0].size(); i++) {
pq.push(sasiedzi[0][i]);
}
sendInt(pq.top().first,9);
}
void ReceiveB(bool y){
if(stan == 9){
czyt*=2;
czyt+=y;
akbit++;
if(akbit==9){
if(liczbaodwiedzonych==n)
return;
liczbaodwiedzonych++;
while(!pq.empty() && odwiedzone[pq.top().second])
pq.pop();
if(pq.empty())
pq.push({510,2137});
if(pq.top().first-last>czyt){
odwiedzone[pq.top().second] = 1;
answer[pq.top().second] = pq.top().first.first;
for (int i = 0; i < (int)sasiedzi[pq.top().second].size(); i++) {
pq.push({ sasiedzi[pq.top().second][i].first + pq.top().first + last,sasiedzi[pq.top().second][i].second });
}
last+ = pq.top().first;
czyt=0;
sendInt(pq.top().second,11);
pq.pop();
while(!pq.empty() && odwiedzone[pq.top().second])
pq.pop();
if(pq.empty())
pq.push({510,2137});
sendInt(pq.top().first-last,9);
}
else{
stan=11;
}
akbit=0;
}
}
if(stan==11){
czyt2*=2;
czyt2+=y;
akbit++;
if(akbit==11){
akbit=0;
answer[czyt2]=czyt+last;
for (int i = 0; i < (int)sasiedzi[czyt2].size(); i++) {
pq.push({ sasiedzi[czyt2][i].first + czyt + last,sasiedzi[pq.top().second][i].second });
}
czyt=0;
czyt2=0;
while(!pq.empty() && odwiedzone[pq.top().second])
pq.pop();
if(pq.empty())
pq.push({510,2137});
sendInt(pq.top().first-last-czyt,9);
last+=czyt;
}
}
}
Compilation message
Azer.cpp: In function 'void sendInt(int, int)':
Azer.cpp:17:9: error: 'SendA' was not declared in this scope
17 | SendA(v[i]);
| ^~~~~
Azer.cpp: In function 'void InitA(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
Azer.cpp:29:30: error: 'sasiedzi1' was not declared in this scope; did you mean 'sasiedzi'?
29 | for (int i = 0; i < (int)sasiedzi1[0].size(); i++) {
| ^~~~~~~~~
| sasiedzi
Azer.cpp:34:22: error: a function-definition is not allowed here before '{' token
34 | void ReceiveA(bool y){
| ^
Azer.cpp:92:20: error: a function-definition is not allowed here before '{' token
92 | vector<int>Answer(){
| ^
Azer.cpp:94:1: error: expected '}' at end of input
94 | }
| ^
Azer.cpp:20:68: note: to match this '{'
20 | void InitA(int N, int A, vector<int>U, vector<int>V, vector<int>C) {
| ^
Baijan.cpp: In function 'void sendInt(int, int)':
Baijan.cpp:17:9: error: 'SendB' was not declared in this scope
17 | SendB(v[i]);
| ^~~~~
Baijan.cpp: In function 'void InitB(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
Baijan.cpp:25:25: error: 'A' was not declared in this scope
25 | for (int i = 0; i < A; i++) {
| ^
Baijan.cpp:29:30: error: 'sasiedzi1' was not declared in this scope; did you mean 'sasiedzi'?
29 | for (int i = 0; i < (int)sasiedzi1[0].size(); i++) {
| ^~~~~~~~~
| sasiedzi
Baijan.cpp:34:22: error: a function-definition is not allowed here before '{' token
34 | void ReceiveB(bool y){
| ^
Baijan.cpp:91:1: error: expected '}' at end of input
91 | }
| ^
Baijan.cpp:20:68: note: to match this '{'
20 | void InitB(int N, int B, vector<int>U, vector<int>V, vector<int>C) {
| ^