Submission #836513

#TimeUsernameProblemLanguageResultExecution timeMemory
836513gustasonTwo Transportations (JOI19_transportations)C++14
0 / 100
139 ms6824 KiB
#include "Azer.h" #include <bits/stdc++.h> using namespace std; namespace { const int nax = 2005; int N; std::vector<int> dist; priority_queue<array<int, 2>> q; const int INF = 1000001; vector<array<int, 2>> adj[nax]; vector<int> gauti_bitai; void siusk(int x, int bitai) { for(int i = 0; i < bitai; i++) { bool b = ((x & (1<<i)) != 0); SendA(b); } } void go() { while(!q.empty()) { int w = -q.top()[0]; int v = q.top()[1]; q.pop(); // nusiunciu kandidato w siusk(w, 20); // nusiunciu kandidato v siusk(v, 11); //cout << "checkA " << v << " " << w << "\n"; for(auto& u : adj[v]) { if (w + u[1] < dist[u[0]]) { dist[u[0]] = w + u[1]; q.push({-dist[u[0]], u[0]}); } } } } void upd(int v, int w) { if (dist[v] <= w) return; //cout << "updA " << v << " " << w << "\n"; dist[v] = w; //cout << "upd: " << v << " " << w << "\n"; for(auto& u : adj[v]) { if (w + u[1] < dist[u[0]]) { dist[u[0]] = w + u[1]; q.push({-dist[u[0]], u[0]}); } } go(); } } // namespace void InitA(int N, int A, std::vector<int> U, std::vector<int> V, std::vector<int> C) { ::N = N; dist.assign(N, INF); for(int i = 0 ; i < A; i++) { adj[U[i]].push_back({V[i], C[i]}); adj[V[i]].push_back({U[i], C[i]}); } upd(0, 0); } void ReceiveA(bool x) { gauti_bitai.push_back(x); if (gauti_bitai.size() == 31) { int w = 0, v = 0; for(int i = 0; i < 20; i++) { if (gauti_bitai[i]) { w += 1<<i; } } for(int i = 20; i < 31; i++) { if (gauti_bitai[i]) { v += 1<<(i-20); } } gauti_bitai.clear(); //cout << "A gavo " << v << " " << w << "\n"; upd(v, w); } } std::vector<int> Answer() { return dist; }
#include "Baijan.h" #include <bits/stdc++.h> using namespace std; namespace { const int nax = 2005; int N; std::vector<int> dist; priority_queue<array<int, 2>> q; const int INF = 1000001; vector<array<int, 2>> adj[nax]; vector<int> gauti_bitai; void siusk(int x, int bitai) { for(int i = 0; i < bitai; i++) { bool b = ((x & (1<<i)) != 0); SendB(b); } } void go() { while(!q.empty()) { int w = -q.top()[0]; int v = q.top()[1]; q.pop(); // nusiunciu kandidato w siusk(w, 20); //nusiunciu skandidato v siusk(v, 11); //cout << "checkB " << v << " " << w << "\n"; for(auto& u : adj[v]) { if (w + u[1] < dist[u[0]]) { dist[u[0]] = w + u[1]; q.push({-dist[u[0]], u[0]}); } } } } void upd(int v, int w) { if (dist[v] <= w) return; //cout << "updB " << v << " " << w << "\n"; dist[v] = w; for(auto& u : adj[v]) { if (w + u[1] < dist[u[0]]) { dist[u[0]] = w + u[1]; q.push({-dist[u[0]], u[0]}); //cout << "naujas " << u[0] << " " << dist[u[0]] << "\n"; } } go(); } } // namespace void InitB(int N, int A, std::vector<int> U, std::vector<int> V, std::vector<int> C) { ::N = N; dist.assign(N, INF); for(int i = 0 ; i < A; i++) { adj[U[i]].push_back({V[i], C[i]}); adj[V[i]].push_back({U[i], C[i]}); } upd(0, 0); } void ReceiveB(bool y) { gauti_bitai.push_back(y); if (gauti_bitai.size() == 31) { int w = 0, v = 0; for(int i = 0; i < 20; i++) { if (gauti_bitai[i]) { w += 1<<i; } } for(int i = 20; i < 31; i++) { if (gauti_bitai[i]) { v += 1<<(i-20); } } gauti_bitai.clear(); //cout << "B gavo " << v << " " << w << "\n"; upd(v, w); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...