Submission #776329

#TimeUsernameProblemLanguageResultExecution timeMemory
776329PiokemonTwo Transportations (JOI19_transportations)C++17
0 / 100
1 ms456 KiB
#include "Azer.h" #include <bits/stdc++.h> using namespace std; typedef long long int ll; namespace { int n; int dst[1009]; int nr=0; int wczyt,ter; pair<int,int> cel; vector<pair<int,int>> graf[1009]; priority_queue<pair<int,int>> djik; void napisz(int v, int d){ for (int x=0;x<d;x++) SendA(v & (1<<x)); } void oblicz(int v, int d){ if (dst[v]>d){ dst[v] = d; for (pair<int,int> x:graf[v]){ if (dst[x.first] > dst[v] + x.second){ dst[x.first] = dst[v] + x.second; djik.push({-dst[x.first],x.first}); } } } while(dst[djik.top().first] != -djik.top().second) djik.pop(); if (djik.empty()){ djik.push({-1e9,1}); } nr++; napisz(-djik.top().first,21); napisz(djik.top().second,10); } } // namespace void InitA(int N, int A, std::vector<int> U, std::vector<int> V, std::vector<int> C) { n= N; for (int x=0;x<A;x++){ graf[U[x]].push_back({V[x],C[x]}); graf[V[x]].push_back({U[x],C[x]}); } for (int x=0;x<=n;x++) dst[x] = 1e9; wczyt = 0; ter = 0; oblicz(0,0); } void ReceiveA(bool x) { if (nr>n+2) return; if (ter>=21) wczyt += x * (1<<(ter-21)); else wczyt += x * (1<<ter); if (ter==21){ cel.second = wczyt; wczyt = 0; } else if (ter==31){ cel.first = wczyt; wczyt = 0; if (-djik.top().first <= cel.second){ pair<int,int> temp = djik.top(); djik.pop(); oblicz(temp.second,-temp.first); } else{ oblicz(cel.first,cel.second); } } } std::vector<int> Answer() { std::vector<int> ans(n); for (int k = 0; k < n; ++k) { ans[k] = dst[k]; } return ans; }
#include "Baijan.h" #include <bits/stdc++.h> using namespace std; typedef long long int ll; namespace { int n; int dst[1009]; int nr=0; int wczyt,ter; pair<int,int> cel; vector<pair<int,int>> graf[1009]; priority_queue<pair<int,int>> djik; void napisz(int v, int d){ for (int x=0;x<d;x++) SendB(v & (1<<x)); } void oblicz(int v, int d){ if (dst[v]>d){ dst[v] = d; for (pair<int,int> x:graf[v]){ if (dst[x.first] > dst[v] + x.second){ dst[x.first] = dst[v] + x.second; djik.push({-dst[x.first],x.first}); } } } while(dst[djik.top().first] != -djik.top().second) djik.pop(); if (djik.empty()){ djik.push({-1e9,1}); } nr++; } } // namespace void InitB(int N, int B, std::vector<int> S, std::vector<int> T, std::vector<int> D) { n= N; for (int x=0;x<B;x++){ graf[S[x]].push_back({T[x],D[x]}); graf[T[x]].push_back({S[x],D[x]}); } for (int x=0;x<=n;x++) dst[x] = 1e9; wczyt = 0; ter = 0; oblicz(0,0); } void ReceiveB(bool y) { if (nr>n+2) return; if (ter>=21) wczyt += y * (1<<(ter-21)); else wczyt += y * (1<<ter); if (ter==21){ cel.second = wczyt; wczyt = 0; } else{ cel.first = wczyt; wczyt = 0; napisz(-djik.top().first,21); napisz(djik.top().second,10); if (-djik.top().second < cel.second){ pair<int,int> temp = djik.top(); djik.pop(); oblicz(temp.first,-temp.second); } else{ oblicz(cel.first,cel.second); } } }
#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...