## Submission #983652

# Submission time Handle Problem Language Result Execution time Memory
983652 2024-05-15T20:40:18 Z Zbyszek99 Two Transportations (JOI19_transportations) C++17
0 / 100
165 ms 588 KB
```#include <bits/stdc++.h>
#include "Azer.h"
#define ff first
#define ss second
using namespace std;

struct Compare {
bool operator()(pair<int,int> a, pair<int,int> b) {
return a > b;
}
};

int GETTING_VAL= 0;
int GETTING_V = 1;

int ans[2001];
int n,m;
vector<pair<int,int>> graf[2001];
priority_queue<pair<int,int>, vector<pair<int,int>>, Compare> pri;
int akt_odl;
int oper;
int how_many_bits;
int num;
int new_v;
int tryb;
void SendNum(int x, int wiel)
{
for(int bit = 0; bit < wiel; bit++)
{
if(x & (1 << bit))
{
SendA(1);
}
else
{
SendA(0);
}
}
}

void InitA(int N, int M, std::vector<int> U, std::vector<int> V, std::vector<int> C)
{
// odw[0] = 1;
ans[0] = 0;
n = N;
m = M;
for(int i = 0; i < m; i++)
{
graf[U[i]].push_back({C[i],V[i]});
graf[V[i]].push_back({C[i],U[i]});
}
for(auto& it: graf[0])
{
pri.push(it);
}
pair<int,int> t = pri.top();
SendNum(t.ff - akt_odl,9);
}

{
if(tryb == GETTING_VAL)
{
if(x) num += (1 << how_many_bits);
how_many_bits++;
if(how_many_bits == 9)
{

oper++;
if(oper == n) return;
while((int)pri.size() != 0 && (ans[pri.top().ss] != 0 || pri.top().ss == 0)) pri.pop();
if(pri.size() == 0) pri.push({501,2000});
//cout << num << " val A\n";
// cout << "ja: " << pri.top().ff - akt_odl << ", B: " << num << "\n";
if(pri.top().ff - akt_odl <= num)
{
//    cout << "Sending to B: " << pri.top().ss << " info about v\n";
SendNum(pri.top().ss,11);
akt_odl = pri.top().ff;
ans[pri.top().ss] = akt_odl;
for(auto& it: graf[pri.top().ss])
{
pri.push({it.ff + akt_odl, it.ss});
}
how_many_bits = 0;
num = 0;
pri.pop();
while((int)pri.size() != 0 && (ans[pri.top().ss] != 0 || pri.top().ss == 0)) pri.pop();
if(pri.size() == 0) pri.push({501,2000});
//   cout << "Sending to B: " << pri.top().ff - akt_odl << " info about min\n";
SendNum(pri.top().ff - akt_odl,9); //only for Azer
}
else
{
new_v = 0;
how_many_bits = 0;
tryb = GETTING_V;
}
}
}
else
{
if(x) new_v += (1 << how_many_bits);
how_many_bits++;
if(how_many_bits == 11)
{
//  cout << new_v << "new_v A\n";
tryb = GETTING_VAL;
ans[new_v] = akt_odl+num;
akt_odl += num;
//odw[new_v] = 1;
// cout << akt_odl << " akt_odl A\n";
for(auto& it: graf[new_v])
{
pri.push({it.ff + akt_odl, it.ss});

}
how_many_bits = 0;
num = 0;
while((int)pri.size() != 0 && (ans[pri.top().ss] != 0 || pri.top().ss == 0)) pri.pop();
if(pri.size() == 0) pri.push({501,2000});
//  cout << "Sending to B: " << pri.top().ff - akt_odl << " info about min\n";
SendNum(pri.top().ff - akt_odl,9);
}
}
}

{
vector<int> ans2;
for(int i = 0; i < n; i++) ans2.push_back(ans[i]);
return ans2;
}```
```#include <bits/stdc++.h>
#include "Baijan.h"
#define ff first
#define ss second
using namespace std;

namespace {

struct Compare {
bool operator()(pair<int,int> a, pair<int,int> b) {
return a > b;
}
};

int GETTING_VAL= 0;
int GETTING_V = 1;

int ans[2001];
int n,m;
vector<pair<int,int>> graf[2001];
priority_queue<pair<int,int>, vector<pair<int,int>>, Compare> pri;
int akt_odl;
int oper;
int how_many_bits;
int num;
int new_v;
int tryb;
void SendNum(int x, int wiel)
{
for(int bit = 0; bit < wiel; bit++)
{
if(x & (1 << bit))
{
SendB(1);
}
else
{
SendB(0);
}
}
}

}

void InitB(int N, int M, vector<int> U, vector<int> V, vector<int> cost)
{
ans[0] = 0;
n = N;
m = M;
for(int i = 0; i < m; i++)
{
graf[U[i]].push_back({cost[i],V[i]});
graf[V[i]].push_back({cost[i],U[i]});
}
for(auto& it: graf[0])
{
pri.push(it);
}
pair<int,int> t = pri.top();
SendNum(t.ff - akt_odl,9);
}

{
if(tryb == GETTING_VAL)
{
if(x) num += (1 << how_many_bits);
how_many_bits++;
if(how_many_bits == 9)
{
// cout << num << " val B\n";
oper++;
if(oper == n) return;
while((int)pri.size() != 0 && (ans[pri.top().ss] != 0 || pri.top().ss == 0)) pri.pop();
if(pri.size() == 0) pri.push({501,2000});
//cout << "ja: " << pri.top().ff - akt_odl << ", A: " << num << "\n";
if(pri.top().ff - akt_odl < num)
{
//cout << "Sending to A: " << pri.top().ss << " info about v\n";
SendNum(pri.top().ss,11);
akt_odl = pri.top().ff;
ans[pri.top().ss] = akt_odl;
for(auto& it: graf[pri.top().ss])
{
pri.push({it.ff + akt_odl, it.ss});
}
how_many_bits = 0;
num = 0;
pri.pop();
while((int)pri.size() != 0 && (ans[pri.top().ss] != 0 || pri.top().ss == 0)) pri.pop();
if(pri.size() == 0) pri.push({501,2000});
// cout << "Sending to A: " << pri.top().ff - akt_odl << " info about min\n";
SendNum(pri.top().ff - akt_odl,9); //only for Azer
}
else
{
new_v = 0;
how_many_bits = 0;
tryb = GETTING_V;
}
}
}
else
{
if(x) new_v += (1 << how_many_bits);
how_many_bits++;
if(how_many_bits == 11)
{
//cout << new_v << "new_v B\n";
tryb = GETTING_VAL;
ans[new_v] = akt_odl+num;
akt_odl += num;
for(auto& it: graf[new_v])
{
pri.push({it.ff + akt_odl, it.ss});
//    cout << it.ss << " nowy B\n";
}
how_many_bits = 0;
num = 0;
while((int)pri.size() != 0 && (ans[pri.top().ss] != 0 || pri.top().ss == 0)) pri.pop();
if(pri.size() == 0) pri.push({501,2000});
//  cout << pri.top().ss << " nowy_max B\n";
// cout << "Sending to A: " << pri.top().ff - akt_odl << " info about min\n";
SendNum(pri.top().ff - akt_odl,9);
}
}
}```

#### Subtask #1 0 / 6.0

# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 588 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -

#### Subtask #2 0 / 8.0

# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 588 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -

#### Subtask #3 0 / 8.0

# Verdict Execution time Memory Grader output
1 Runtime error 165 ms 536 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -

#### Subtask #4 0 / 38.0

# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 588 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -

#### Subtask #5 0 / 14.0

# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 588 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -

#### Subtask #6 0 / 10.0

# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 588 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -

#### Subtask #7 0 / 16.0

# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 588 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -