Submission #776364

#TimeUsernameProblemLanguageResultExecution timeMemory
776364PiokemonTwo Transportations (JOI19_transportations)C++17
0 / 100
404 ms656 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){ //cout << "A: " << v << ' ' << d << '\n'; 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(!djik.empty() && dst[djik.top().second] != -djik.top().first) 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, vector<int> U, vector<int> V, 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) return; if (ter>=21) wczyt += x * (1<<(ter-21)); else wczyt += x * (1<<ter); ter++; if (ter==21){ cel.second = wczyt; wczyt = 0; } else if (ter==31){ cel.first = wczyt; wczyt = 0; ter=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); } } } vector<int> Answer() { 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){ //cout << "B: " << v << ' ' << d << '\n'; 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(!djik.empty() && dst[djik.top().second] != -djik.top().first) djik.pop(); if (djik.empty()){ djik.push({-1e9,1}); } nr++; } } // namespace void InitB(int N, int B, vector<int> S, vector<int> T, 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) return; if (ter>=21) wczyt += y * (1<<(ter-21)); else wczyt += y * (1<<ter); ter++; if (ter==21){ cel.second = wczyt; wczyt = 0; } else if(ter==31){ cel.first = wczyt; wczyt = 0; ter=0; napisz(-djik.top().first,21); napisz(djik.top().second,10); 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); } } }
#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...