제출 #671163

#제출 시각아이디문제언어결과실행 시간메모리
671163MilosMilutinovicTwo Transportations (JOI19_transportations)C++14
0 / 100
2 ms784 KiB
#include "Azer.h" #include <bits/stdc++.h> using namespace std; namespace { int n; vector<int> dist; vector<bool> was; vector<vector<pair<int, int>>> g; int cd = 0; void update(int i) { was[i] = true; cd = dist[i]; for (auto& p : g[i]) { int j = p.first; int w = p.second; if (dist[j] > dist[i] + w) { dist[j] = dist[i] + w; } } } int idx = -1; int s; void send() { for (int i = 0; i < n; i++) { if (was[i]) { continue; } if (idx == -1 || dist[i] < dist[idx]) { idx = i; } } if (idx == -1) { return; } s = dist[idx] - cd; for (int i = 8; i >= 0; i--) { SendA(s >> i & 1); } } int f = 0; int cnt = 0; int state = 1; int tmp = 0; } void InitA(int N, int a, vector<int> u, vector<int> v, vector<int> c) { n = N; dist = vector<int>(n, 1e9); dist[0] = 0; g.resize(n); was.resize(n); for (int i = 0; i < a; ++i) { g[u[i]].emplace_back(v[i], c[i]); g[v[i]].emplace_back(u[i], c[i]); } update(0); send(); } void ReceiveA(bool x) { f = 2 * f + x; if (state == 1) { if (cnt == 9) { if (s <= f) { for (int i = 10; i >= 0; i--) { SendA(idx >> i & 1); } cnt = 0; f = 0; update(idx); send(); } else { tmp = f; f = 0; state = 2; cnt = 0; } } } else if (state == 2) { if (cnt == 11) { dist[f] = cd + tmp; update(f); send(); cnt = 0; f = 0; } } } vector<int> Answer() { vector<int> ans; for (int i = 0; i < n; i++) { ans.push_back(dist[i]); } return ans; }
#include "Baijan.h" #include <bits/stdc++.h> using namespace std; namespace { int n; vector<int> dist; vector<bool> was; vector<vector<pair<int, int>>> g; int cd = 0; void update(int i) { was[i] = true; cd = dist[i]; for (auto& p : g[i]) { int j = p.first; int w = p.second; if (dist[j] > dist[i] + w) { dist[j] = dist[i] + w; } } } int idx = -1; int s; void send() { for (int i = 0; i < n; i++) { if (was[i]) { continue; } if (idx == -1 || dist[i] < dist[idx]) { idx = i; } } if (idx == -1) { return; } s = dist[idx] - cd; for (int i = 8; i >= 0; i--) { SendB(s >> i & 1); } } int f = 0; int cnt = 0; int state = 1; int tmp = 0; } void InitB(int N, int a, vector<int> u, vector<int> v, vector<int> c) { n = N; dist = vector<int>(n, 1e9); dist[0] = 0; g.resize(n); was.resize(n); for (int i = 0; i < a; ++i) { g[u[i]].emplace_back(v[i], c[i]); g[v[i]].emplace_back(u[i], c[i]); } update(0); send(); } void ReceiveB(bool x) { f = 2 * f + x; if (state == 1) { if (cnt == 9) { if (s < f) { assert(idx != -1); for (int i = 10; i >= 0; i--) { SendB(idx >> i & 1); } cnt = 0; f = 0; update(idx); send(); } else { tmp = f; f = 0; state = 2; cnt = 0; } } } else if (state == 2) { if (cnt == 11) { dist[f] = cd + tmp; update(f); send(); cnt = 0; f = 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...