# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
414934 | Pro_ktmr | Two Transportations (JOI19_transportations) | C++17 | 1024 ms | 48948 KiB |
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"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
namespace A{
int N;
vector<pair<int,int>> e[2000];
vector<bool> decided;
int dcnt = 0;
vector<int> cost;
int state = 0;
int cnt = 0;
int send = 0;
int receive = 0;
int idx = 0;
int bef = 0;
priority_queue<pair<int,int>> pq;
void Dijkstra(int n, int v){
v = bef + v;
bef = v;
decided[n] = true;
cost[n] = v;
dcnt++;
if(dcnt == N) return;
//cout << "A1: " << n << " " << v << endl;
rep(i, e[n].size()){
if(cost[e[n][i].first] > v + e[n][i].second){
cost[e[n][i].first] = v + e[n][i].second;
pq.push({-cost[e[n][i].first], e[n][i].first});
}
}
while(!pq.empty() && decided[pq.top().second]) pq.pop();
if(pq.empty()) send = 501;
else send = -pq.top().first - bef;
rep(i, 9) SendA((send>>8-i)&1);
if(pq.empty()) idx = 2000;
else idx = pq.top().second;
//cout << "A2: " << idx << " " << send+bef << endl;
}
} // namespace
void InitA(int _N, int A, vector<int> U, vector<int> V, vector<int> C) {
using namespace A;
N = _N;
rep(i, A){
e[U[i]].pb({V[i], C[i]});
e[V[i]].pb({U[i], C[i]});
}
decided.assign(N, false);
cost.assign(N, INT_MAX);
Dijkstra(0, 0);
}
void ReceiveA(bool x) {
using namespace A;
if(state == 0){
receive = (receive<<1) + x;
cnt++;
if(cnt == 9){
cnt = 0;
if(send <= receive){
rep(i, 11) SendA((idx>>10-i)&1);
Dijkstra(idx, send);
receive = 0;
}
else{
state = 1;
idx = 0;
}
}
}
else{
idx = (idx<<1) + x;
cnt++;
if(cnt == 11){
cnt = 0;
state = 0;
Dijkstra(idx, receive);
receive = 0;
}
}
}
vector<int> Answer() {
using namespace A;
return cost;
}
#include"Baijan.h"
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
namespace B{
int N;
vector<pair<int,int>> e[2000];
vector<bool> decided;
int dcnt = 0;
vector<int> cost;
int state = 0;
int cnt = 0;
int send = 0;
int receive = 0;
int idx = 0;
int bef = 0;
priority_queue<pair<int,int>> pq;
void Dijkstra(int n, int v){
v = bef + v;
bef = v;
decided[n] = true;
cost[n] = v;
dcnt++;
if(dcnt == N) return;
//cout << "B1: " << n << " " << v << endl;
rep(i, e[n].size()){
if(cost[e[n][i].first] > v + e[n][i].second){
cost[e[n][i].first] = v + e[n][i].second;
pq.push({-cost[e[n][i].first], e[n][i].first});
}
}
while(!pq.empty() && decided[pq.top().second]) pq.pop();
if(pq.empty()) send = 501;
else send = -pq.top().first - bef;
rep(i, 9) SendB((send>>8-i)&1);
if(pq.empty()) idx = 2000;
else idx = pq.top().second;
//cout << "B2: " << idx << " " << send+bef << endl;
}
} // namespace
void InitB(int _N, int B, vector<int> S, vector<int> T, vector<int> D) {
using namespace B;
N = _N;
rep(i, B){
e[S[i]].pb({T[i], D[i]});
e[T[i]].pb({S[i], D[i]});
}
decided.assign(N, false);
cost.assign(N, INT_MAX);
Dijkstra(0, 0);
}
void ReceiveB(bool y) {
using namespace B;
if(state == 0){
receive = (receive<<1) + y;
cnt++;
if(cnt == 9){
cnt = 0;
if(send < receive){
rep(i, 11) SendB((idx>>10-i)&1);
Dijkstra(idx, send);
receive = 0;
}
else{
state = 1;
idx = 0;
}
}
}
else{
idx = (idx<<1) + y;
cnt++;
if(cnt == 11){
cnt = 0;
state = 0;
Dijkstra(idx, receive);
receive = 0;
}
}
}
Compilation message (stderr)
# | 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... |