Submission #982514

# Submission time Handle Problem Language Result Execution time Memory
982514 2024-05-14T10:37:13 Z parlimoos Two Transportations (JOI19_transportations) C++14
0 / 100
896 ms 664 KB
//Be Name KHODA
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include "Azer.h"
using namespace std;

typedef long long ll;
typedef long double ld;
#define pb push_back
#define pp pop_back
#define lb lower_bound
#define ub upper_bound
#define cl clear
#define bg begin
#define arr(x) array<int , x>
#define endl '\n'

int nA , mA , dstA[2000];
vector<arr(2)> gA[2000];
set<arr(2)> qA;
int lstA = 0;
int rcvA[3] , xxA[2];
vector<int> AA;
int cnt = 0;

void sendInfA(int x , int len){
    x = min(x , 501);
	for(int bit = len - 1 ; bit >= 0 ; bit--){
        while(++cnt > 58000);
        SendA((x >> bit) & 1);
    }
}
vector<int> Answer(){
    return AA;
}
void addVtxA(int v , int x){
    while(cnt > 58000);
    v = min(v , nA);
    // if(v >= nA) exit(0);
    qA.erase({dstA[v] , v});
	dstA[v] = x , lstA = x;
	for(auto &e : gA[v]){
		if(dstA[e[0]] > dstA[v] + e[1]){
			qA.erase({dstA[e[0]] , e[0]});
			dstA[e[0]] = dstA[v] + e[1];
			qA.insert({dstA[e[0]] , e[0]});
		}
	}
    if(qA.empty()){
        for(int i = 0 ; i < nA ; i++) AA.pb(dstA[i]);
        return;
    }
	auto itr = qA.bg();
	rcvA[0] = 9 , rcvA[1] = 0 , rcvA[2] = 0;
	xxA[0] = (*itr)[1] , xxA[1] = (*itr)[0] - lstA;
	sendInfA((*itr)[0] - lstA , 9);
}
void gotLenA(int len){
	if(xxA[1] <= len){
    sendInfA(xxA[0] , 11);
    addVtxA(xxA[0] , xxA[1] + lstA);
	}else{
		xxA[1] = len , rcvA[0] = 11 , rcvA[1] = 0 , rcvA[2] = 1;
	}
}
void ReceiveA(bool x){
    while(++cnt > 58000);
	rcvA[1] += (x << (rcvA[0] - 1));
	if(--rcvA[0] == 0){
		if(rcvA[2] == 0) gotLenA(rcvA[1]);
		else{
            addVtxA(rcvA[1] , xxA[1] + lstA);
        }
	}
}
void InitA(int N , int A , vector<int> U , vector<int> V , vector<int> C){
	nA = N , mA = A;
    fill(&dstA[0] , &dstA[nA] , int(1e9));
    for(int v = 0 ; v < nA ; v++) qA.insert({dstA[v] , v});
	for(int i = 0 ; i < mA ; i++) gA[U[i]].pb({V[i] , C[i]}) , gA[V[i]].pb({U[i] , C[i]});
	addVtxA(0 , 0);
}
//Be Name KHODA
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include "Baijan.h"
using namespace std;

typedef long long ll;
typedef long double ld;
#define pb push_back
#define pp pop_back
#define lb lower_bound
#define ub upper_bound
#define cl clear
#define bg begin
#define arr(x) array<int , x>
#define endl '\n'

int nB , mB , dstB[2000];
vector<arr(2)> gB[2000];
set<arr(2)> qB;
int lstB = 0;
int rcvB[3] , xxB[2];

void sendInfB(int x , int len){
    x = min(x , 501);
	for(int bit = len - 1 ; bit >= 0 ; bit--) SendB((x >> bit) & 1);
}
void addVtxB(int v , int x){
    v = min(nB , v);
    qB.erase({dstB[v] , v});
	dstB[v] = x , lstB = x;
	for(auto &e : gB[v]){
		if(dstB[e[0]] > dstB[v] + e[1]){
			qB.erase({dstB[e[0]] , e[0]});
			dstB[e[0]] = dstB[v] + e[1];
			qB.insert({dstB[e[0]] , e[0]});
		}
	}
	auto itr = qB.bg();
	rcvB[0] = 9 , rcvB[1] = 0 , rcvB[2] = 0;
	xxB[0] = (*itr)[1] , xxB[1] = (*itr)[0] - lstB;
}
void gotLenB(int len){
	if(xxB[1] <= len){
		sendInfB(xxB[1] , 9);
        sendInfB(xxB[1] , 11);
        addVtxB(xxB[0] , xxB[1] + lstB);
	}else{
        int d = xxB[1];
        rcvB[0] = 11 , rcvB[1] = 0 , rcvB[2] = 1 , xxB[1] = len;
        sendInfB(d , 9);
	}
}
void ReceiveB(bool x){
	rcvB[1] += (x << (rcvB[0] - 1));
	if(--rcvB[0] == 0){
		if(rcvB[2] == 0) gotLenB(rcvB[1]);
		else addVtxB(rcvB[1] , xxB[1] + lstB);
	}
}
void InitB(int N , int B , vector<int> S , vector<int> T , vector<int> D){
	nB = N , mB = B;
    fill(&dstB[0] , &dstB[nB] , int(1e9));
    for(int v = 0 ; v < nB ; v++) qB.insert({dstB[v] , v});
	for(int i = 0 ; i < mB ; i++) gB[T[i]].pb({S[i] , D[i]}) , gB[S[i]].pb({T[i] , D[i]});
	addVtxB(0 , 0);
}

Compilation message

Azer.cpp: In function 'void ReceiveA(bool)':
Azer.cpp:67:5: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   67 |     while(++cnt > 58000);
      |     ^~~~~
Azer.cpp:68:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
   68 |  rcvA[1] += (x << (rcvA[0] - 1));
      |  ^~~~
# Verdict Execution time Memory Grader output
1 Runtime error 896 ms 552 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 664 KB Output is correct
2 Incorrect 1 ms 588 KB Wrong Answer [1]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 644 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 42 ms 332 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 42 ms 332 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 42 ms 332 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 896 ms 552 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -