Submission #836410

#TimeUsernameProblemLanguageResultExecution timeMemory
836410unnickTwo Transportations (JOI19_transportations)C++14
0 / 100
216 ms4364 KiB
#include "Azer.h" #include <iostream> #include <vector> #include <queue> using namespace std; typedef struct { int to; int w; } edge_t; namespace { int N; int A; vector<int> U; vector<int> V; vector<int> C; bool defer_to_b; int bit_idx = 0; vector< vector<edge_t> > vts; vector<bool> bits; bool read_bool() { return bits[bit_idx++]; } int read_int(int b) { int x = 0; for (int i = 0; i < b; i++) { x += ((int) read_bool()) << i; } return x; } void send_int(int x, int b) { for (int i = 0; i < b; i++) { SendA((x>>i)&1); } } } // namespace void InitA(int N, int A, std::vector<int> U, std::vector<int> V, std::vector<int> C) { ::N = N; ::A = A; ::U = U; ::V = V; ::C = C; send_int(A, 19); // for (int i = 0; i < N; i++) { // vector<edge_t> tmp; // vts.push_back(tmp); // } // for (int i = 0; i < A; i++) { // vts[U[i]].push_back({.to = V[i], .w = C[i]}); // vts[V[i]].push_back({.to = U[i], .w = C[i]}); // } } void ReceiveA(bool x) { bits.push_back(x); if (bits.size() == 1) { defer_to_b = read_bool(); if (defer_to_b) { for (int i = 0; i < A; i++) { send_int(U[i], 11); send_int(V[i], 11); send_int(C[i], 9); } } } } std::vector<int> Answer() { vector<int> ans(N,2000000000); if (defer_to_b) { for (int i = 0; i < N; i++) { ans[i] = read_int(19); } return ans; } for (int i = 0; i < N; i++) { vector<edge_t> tmp; vts.push_back(tmp); } for (int i = 0; i < A; i++) { vts[U[i]].push_back({.to = V[i], .w = C[i]}); vts[V[i]].push_back({.to = U[i], .w = C[i]}); } while (bit_idx < bits.size()) { int u = read_int(11); int v = read_int(11); int c = read_int(9); vts[u].push_back({.to = v, .w = c}); vts[v].push_back({.to = u, .w = c}); } ans[0] = 0; auto cmp = [](edge_t a, edge_t b){ return a.w>b.w; }; vector<bool> visited(N, false); priority_queue<edge_t, vector<edge_t>, decltype(cmp)> queue(cmp); queue.push({.to=0, .w=0}); while (!queue.empty()) { edge_t e = queue.top(); queue.pop(); if (visited[e.to]) continue; visited[e.to] = true; ans[e.to] = e.w; for (edge_t e2 : vts[e.to]) { // if (visited[e2.to]) continue; e2.w += e.w; queue.push(e2); } } return ans; }
#include "Baijan.h" #include <iostream> #include <vector> #include <queue> using namespace std; typedef struct { int to; int w; } edge_t; namespace { int N; vector< vector<edge_t> > vts; int B; int A; std::vector<int> S; std::vector<int> T; std::vector<int> D; bool defer_to_b; int bit_idx = 0; vector<bool> bits; bool read_bool() { return bits[bit_idx++]; } int read_int(int b) { int x = 0; for (int i = 0; i < b; i++) { x += ((int) read_bool()) << i; } return x; } // int count; // bool FunctionExample(bool P) { // return !P; // } void send_int(int x, int b) { for (int i = 0; i < b; i++) { SendB((x>>i)&1); } } } // namespace void InitB(int N, int B, std::vector<int> S, std::vector<int> T, std::vector<int> D) { ::N = N; ::B = B; ::S = S; ::T = T; ::D = D; // count = 0; } void ReceiveB(bool y) { bits.push_back(y); if (bits.size() == 19) { A = read_int(19); defer_to_b = A<B; SendB(defer_to_b); if (!defer_to_b) { for (int i = 0; i < B; i++) { send_int(S[i], 11); send_int(T[i], 11); send_int(D[i], 9); }; } } if (defer_to_b && bits.size() == (19 + A*31)) { for (int i = 0; i < N; i++) { vector<edge_t> tmp; vts.push_back(tmp); } for (int i = 0; i < B; i++) { vts[S[i]].push_back({.to = T[i], .w = D[i]}); vts[T[i]].push_back({.to = S[i], .w = D[i]}); } while (bit_idx < bits.size()) { int u = read_int(11); int v = read_int(11); int c = read_int(9); // cout << u << " " << v << " " << c << "\n"; vts[u].push_back({.to = v, .w = c}); vts[v].push_back({.to = u, .w = c}); } vector<int> ans(N,2000000000); ans[0] = 0; auto cmp = [](edge_t a, edge_t b){ return a.w>b.w; }; vector<bool> visited(N, false); priority_queue<edge_t, vector<edge_t>, decltype(cmp)> queue(cmp); queue.push({.to=0, .w=0}); while (!queue.empty()) { edge_t e = queue.top(); queue.pop(); if (visited[e.to]) continue; visited[e.to] = true; ans[e.to] = e.w; for (edge_t e2 : vts[e.to]) { // if (visited[e2.to]) continue; e2.w += e.w; queue.push(e2); } } for (int i = 0; i < N; i++) { send_int(ans[i], 19); } } // ++count; // if (count < 58000) { // SendB(FunctionExample(y)); // ++count; // } }

Compilation message (stderr)

Azer.cpp: In function 'std::vector<int> Answer()':
Azer.cpp:92:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   92 |   while (bit_idx < bits.size()) {
      |          ~~~~~~~~^~~~~~~~~~~~~

Baijan.cpp: In function 'void ReceiveB(bool)':
Baijan.cpp:77:33: warning: comparison of integer expressions of different signedness: 'std::vector<bool>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   77 |   if (defer_to_b && bits.size() == (19 + A*31)) {
      |                     ~~~~~~~~~~~~^~~~~~~~~~~~~~
Baijan.cpp:86:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<bool>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   86 |     while (bit_idx < bits.size()) {
      |            ~~~~~~~~^~~~~~~~~~~~~
#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...