Submission #1002498

#TimeUsernameProblemLanguageResultExecution timeMemory
1002498kachim2Two Transportations (JOI19_transportations)C++17
14 / 100
416 ms13580 KiB
#include "Azer.h" #include <functional> #include <iostream> #include <queue> #include <vector> namespace { int N, A; int variable_example[500000]; bool visited[500000]{0}; int countv = 1; std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int>>, std::greater<std::pair<int, int>>> q; std::pair<int, int> currently_recieving; int recieved = 0, prev = 0; std::vector<std::vector<std::pair<int, int>>> graph(2005); // namespace int senrec = 0; void sendnbit(int bits, int num) { for (int i = 0; i < bits; i++) { SendA(num >> (bits - 1) & 1); num <<= 1; senrec++; if(senrec>=58000) while(true); } } } // namespace void InitA(int N, int A, std::vector<int> U, std::vector<int> V, std::vector<int> C) { visited[0] = 1; ::N = N; ::A = A; for (int i = 0; i < A; ++i) { graph[U[i]].push_back({V[i], C[i]}); graph[V[i]].push_back({U[i], C[i]}); } for (auto a : graph[0]) { q.push({a.second, a.first}); } currently_recieving = {0, 9}; if (!q.empty()) { sendnbit(9, q.top().first - prev); } else { sendnbit(9, 511); } } void ReceiveA(bool x) { senrec++; if(senrec>=58000) while(true); currently_recieving.first++; recieved <<= 1; recieved |= (int)x; if (currently_recieving.first == currently_recieving.second) { std ::cerr << ' '; if (currently_recieving.second == 9) { while (!q.empty()) if (visited[q.top().second]) { q.pop(); } else break; if (q.empty()) { currently_recieving = {0, 11}; prev = recieved + prev; } else if (q.top().first <= recieved + prev) { sendnbit(11, q.top().second ); prev = q.top().first; variable_example[q.top().second] = q.top().first; visited[q.top().second] = true; countv++; auto p = q.top(); q.pop(); for (auto a : graph[p.second]) { if (!visited[a.first]) q.push({a.second + prev, a.first}); } if (countv != N) { if (!q.empty()) { sendnbit(9, q.top().first - prev); } else { sendnbit(9, 511); } } currently_recieving = {0, 9}; } else { currently_recieving = {0, 11}; prev = recieved + prev; } } else { countv++; visited[recieved] = 1; variable_example[recieved] = prev; for (auto a : graph[recieved]) { if (!visited[a.first]) q.push({a.second + prev, a.first}); } if (countv != N) { if (!q.empty()) { sendnbit(9, q.top().first - prev); } else { sendnbit(9, 511); } } currently_recieving = {0, 9}; } recieved = 0; } } std::vector<int> Answer() { std::vector<int> ans(N); for (int k = 0; k < N; ++k) { ans[k] = variable_example[k]; } return ans; }
#include "Baijan.h" #include <functional> #include <iostream> #include <queue> #include <vector> namespace { int N, A, senrec=0; int variable_example[500000]; bool visited[500000]{0}; int countv = 0; std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int>>, std::greater<std::pair<int, int>>> q; std::pair<int, int> currently_recieving; int recieved = 0, prev = 0; std::vector<std::vector<std::pair<int, int>>> graph(2005); // namespace void sendnbit(int bits, int num) { for (int i = 0; i < bits; i++) { SendB(num >> (bits - 1) & 1); num <<= 1; senrec++; if(senrec>=58000) while(true); } } } // namespace void InitB(int N, int A, std::vector<int> U, std::vector<int> V, std::vector<int> C) { visited[0] = 1; ::N = N; ::A = A; for (int i = 0; i < A; ++i) { graph[U[i]].push_back({V[i], C[i]}); graph[V[i]].push_back({U[i], C[i]}); } for (auto a : graph[0]) { q.push({a.second, a.first}); } currently_recieving = {0, 9}; } void ReceiveB(bool x) { senrec++; if(senrec>=58000) while(true); currently_recieving.first++; recieved <<= 1; recieved |= (int)x; if (currently_recieving.first == currently_recieving.second) { std ::cerr << ' '; if (currently_recieving.second == 9) { while (!q.empty()) if (visited[q.top().second]) { q.pop(); } else break; if (q.empty()) { sendnbit(9, 511); } else { sendnbit(9, q.top().first - prev); } if (q.empty()) { currently_recieving = {0, 11}; prev = recieved + prev; } else if (q.top().first < recieved + prev) { sendnbit(11, q.top().second ); prev = q.top().first; variable_example[q.top().second] = q.top().first; visited[q.top().second] = true; countv++; auto p = q.top(); q.pop(); for (auto a : graph[p.second]) { if (!visited[a.first]) q.push({a.second + prev, a.first}); } if (countv != N) { } currently_recieving = {0, 9}; } else { currently_recieving = {0, 11}; prev = recieved + prev; } } else { countv++; visited[recieved] = 1; variable_example[recieved] = prev; for (auto a : graph[recieved]) { if (!visited[a.first]) q.push({a.second + prev, a.first}); } currently_recieving = {0, 9}; } recieved = 0; } }
#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...