Submission #1041883

#TimeUsernameProblemLanguageResultExecution timeMemory
1041883juicyTwo Transportations (JOI19_transportations)C++17
6 / 100
364 ms10340 KiB
#include "Azer.h" #include <bits/stdc++.h> using namespace std; namespace { void __print() { cerr << "]\n"; } template<class T, class... V> void __print(T t, V... v) { cerr << t; if (sizeof...(v)) { cerr << ", "; } __print(v...); } #define debug(x...) cerr << "[" << #x << "] = ["; __print(x); const int inf = 1e9; int N, MX, value, ind, cur, best, ver; vector<int> D; vector<bool> vis; vector<vector<array<int, 2>>> g; void send(int x, int b) { for (int i = 0; i < b; ++i) { SendA(x >> i & 1); } } void add(int u) { vis[u] = 1; MX = D[u]; for (auto [v, w] : g[u]) { D[v] = min(D[v], D[u] + w); } } void upd() { ind = -1; for (int i = 0; i < N; ++i) { if (!vis[i] && (ind == -1 || D[i] < D[ind])) { ind = i; } } if (~ind) { best = min(501, D[ind] - MX); send(best, 9); } } } void ReceiveA(bool x) { if (cur < 9) { if (x) { value += 1 << cur; } if (++cur == 9 && best < value) { send(ind, 11); add(ind); value = cur = 0; upd(); } } else { if (x) { ver += 1 << cur - 9; } if (++cur == 20) { D[ver] = min(D[ver], value + MX); add(ver); value = cur = ver = 0; upd(); } } } void InitA(int N, int M, std::vector<int> U, std::vector<int> V, std::vector<int> C) { ::N = N; vis.resize(N); g.resize(N); D.resize(N, inf); MX = 0; for (int i = 0; i < M; ++i) { g[U[i]].push_back({V[i], C[i]}); g[V[i]].push_back({U[i], C[i]}); } vis[0] = 1; D[0] = 0; add(0); upd(); } vector<int> Answer() { return D; }
#include "Baijan.h" #include <bits/stdc++.h> using namespace std; namespace { void __print() { cerr << "]\n"; } template<class T, class... V> void __print(T t, V... v) { cerr << t; if (sizeof...(v)) { cerr << ", "; } __print(v...); } #define debug(x...) cerr << "[" << #x << "] = ["; __print(x); const int inf = 1e9; int N, MX, value, ind, cur, best, ver; vector<int> D; vector<bool> vis; vector<vector<array<int, 2>>> g; void send(int x, int b) { for (int i = 0; i < b; ++i) { SendB(x >> i & 1); } } void add(int u) { vis[u] = 1; MX = D[u]; for (auto [v, w] : g[u]) { D[v] = min(D[v], D[u] + w); } } void upd() { ind = -1; for (int i = 0; i < N; ++i) { if (!vis[i] && (ind == -1 || D[i] < D[ind])) { ind = i; } } if (~ind) { best = min(501, D[ind] - MX); send(best, 9); } } } void InitB(int N, int M, std::vector<int> S, std::vector<int> T, std::vector<int> W) { ::N = N; g.resize(N); vis.resize(N); D.resize(N, inf); MX = 0; for (int i = 0; i < M; ++i) { g[S[i]].push_back({T[i], W[i]}); g[T[i]].push_back({S[i], W[i]}); } vis[0] = 1; D[0] = 0; add(0); upd(); } void ReceiveB(bool y) { if (cur < 9) { if (y) { value += 1 << cur; } if (++cur == 9 && best < value) { send(ind, 11); add(ind); value = cur = 0; upd(); } } else { if (y) { ver += 1 << cur - 9; } if (++cur == 20) { D[ver] = min(D[ver], value + MX); add(ver); value = cur = ver = 0; upd(); } } }

Compilation message (stderr)

Azer.cpp: In function 'void ReceiveA(bool)':
Azer.cpp:72:23: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   72 |       ver += 1 << cur - 9;
      |                   ~~~~^~~
Azer.cpp: At global scope:
Azer.cpp:8:8: warning: 'void {anonymous}::__print()' defined but not used [-Wunused-function]
    8 |   void __print() {
      |        ^~~~~~~

Baijan.cpp: In function 'void ReceiveB(bool)':
Baijan.cpp:88:23: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   88 |       ver += 1 << cur - 9;
      |                   ~~~~^~~
Baijan.cpp: At global scope:
Baijan.cpp:9:8: warning: 'void {anonymous}::__print()' defined but not used [-Wunused-function]
    9 |   void __print() {
      |        ^~~~~~~
#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...