Submission #983656

# Submission time Handle Problem Language Result Execution time Memory
983656 2024-05-15T21:07:01 Z Zbyszek99 Two Transportations (JOI19_transportations) C++17
6 / 100
544 ms 13488 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);
}
pri.push({1e9,2000});
pair<int,int> t = pri.top();
SendNum(min(t.ff - akt_odl,501),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({1e9,2000});
//cout << num << " val A\n";
//cout << "ja: " << pri.top().ff - akt_odl  << ", B: " << num << " akt_odl:"<< akt_odl<<"\n";
if((pri.top().ff - akt_odl <= num && pri.top().ff != 1e9) || num == 501)
{
//   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({1e9,2000});
//  cout << "Sending to B: " << min(pri.top().ff - akt_odl,501) << " info about min\n";
SendNum(min(pri.top().ff - akt_odl,501),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({1e9,2000});
// cout << "Sending to B: " << min(pri.top().ff - akt_odl,501) << " info about min\n";
SendNum(min(pri.top().ff - akt_odl,501),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);
}
pri.push({1e9,2000});
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({1e9,2000});
// cout << "ja: " << pri.top().ff - akt_odl << ", A: " << num << " akt_odl:"<< akt_odl<<"\n";
if((pri.top().ff - akt_odl < num && pri.top().ff != 1e9)|| num == 501)
{
//  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({1e9,2000});
//cout << "Sending to A: " << min(pri.top().ff - akt_odl,501) << " info about min\n";
SendNum(min(pri.top().ff - akt_odl,501),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({1e9,2000});
//  cout << pri.top().ss << " nowy_max B\n";
// cout << "Sending to A: " << min(pri.top().ff - akt_odl,501) << " info about min\n";
SendNum(min(pri.top().ff - akt_odl,501),9);
}
}
}```

# Verdict Execution time Memory Grader output
1 Correct 384 ms 1068 KB Output is correct
2 Correct 0 ms 664 KB Output is correct
3 Correct 373 ms 1096 KB Output is correct
4 Correct 544 ms 10492 KB Output is correct
5 Correct 22 ms 1460 KB Output is correct
6 Correct 353 ms 3056 KB Output is correct

# Verdict Execution time Memory Grader output
1 Correct 1 ms 832 KB Output is correct
2 Correct 329 ms 1148 KB Output is correct
3 Incorrect 2 ms 920 KB Output isn't correct
4 Halted 0 ms 0 KB -

# Verdict Execution time Memory Grader output
1 Correct 410 ms 1556 KB Output is correct
2 Correct 0 ms 664 KB Output is correct
3 Correct 390 ms 1060 KB Output is correct
4 Correct 334 ms 1120 KB Output is correct
5 Incorrect 2 ms 896 KB Output isn't correct
6 Halted 0 ms 0 KB -

# Verdict Execution time Memory Grader output
1 Correct 149 ms 820 KB Output is correct
2 Correct 168 ms 788 KB Output is correct
3 Correct 307 ms 13488 KB Output is correct
4 Correct 141 ms 664 KB Output is correct
5 Correct 253 ms 10592 KB Output is correct
6 Incorrect 2 ms 920 KB Output isn't correct
7 Halted 0 ms 0 KB -

# Verdict Execution time Memory Grader output
1 Correct 149 ms 820 KB Output is correct
2 Correct 168 ms 788 KB Output is correct
3 Correct 307 ms 13488 KB Output is correct
4 Correct 141 ms 664 KB Output is correct
5 Correct 253 ms 10592 KB Output is correct
6 Incorrect 2 ms 920 KB Output isn't correct
7 Halted 0 ms 0 KB -

# Verdict Execution time Memory Grader output
1 Correct 149 ms 820 KB Output is correct
2 Correct 168 ms 788 KB Output is correct
3 Correct 307 ms 13488 KB Output is correct
4 Correct 141 ms 664 KB Output is correct
5 Correct 253 ms 10592 KB Output is correct
6 Incorrect 2 ms 920 KB Output isn't correct
7 Halted 0 ms 0 KB -