Submission #1097862

#TimeUsernameProblemLanguageResultExecution timeMemory
1097862thangdz2k7Two Transportations (JOI19_transportations)C++17
100 / 100
615 ms49156 KiB
#include <bits/stdc++.h> #define pb push_back #include "Azer.h" using namespace std; using vi = vector <int>; using ii = pair <int, int>; const int N = 2000; const int inf = 1e9; const int L = 9; const int MaxE = (1 << L) - 1; int n, m, D; vector <ii> adj[N]; vi dist, used; void upd(int x){ used[x] = 1; for (auto [w, v] : adj[x]) dist[v] = min(dist[v], dist[x] + w); } int Node, cnt, X, op, Y; void Send(){ Y = inf; bool ok = false; for (int u = 0; u < n; ++ u) if (!used[u]){ ok = true; if (dist[u] < Y) Y = dist[u], Node = u; } if (!ok) return; op = 1; Y -= D; Y = min(Y, MaxE); for (int i = L - 1; i >= 0; -- i) SendA(Y >> i & 1); } void InitA(int NN, int A, vi U, vi V, vi C){ n = NN, m = A; for (int i = 0; i < A; ++ i) { adj[U[i]].pb({C[i], V[i]}); adj[V[i]].pb({C[i], U[i]}); } dist.resize(n, inf); used.resize(n, 0); dist[0] = 0; D = 0; upd(0); Send(); } void ReceiveA(bool x){ X = X * 2 + x; ++ cnt; if (op == 1){ if (cnt == L){ if (Y <= X){ for (int i = 10; i >= 0; -- i) SendA(Node >> i & 1); D += Y; upd(Node); Send(); cnt = 0, X = 0; } else { D += X; op = 2; cnt = 0; X = 0; } } } else if (op == 2){ if (cnt == 11){ dist[X] = D; upd(X); Send(); cnt = 0; X = 0; } } } vi Answer(){ return dist; }
#include <bits/stdc++.h> #define pb push_back #include "Baijan.h" using namespace std; using vi = vector <int>; using ii = pair <int, int>; const int N = 2000; const int inf = 1e9; const int L = 9; const int MaxE = (1 << L) - 1; int n, m, D; vector <ii> adj[N]; vi dist, used; void upd(int x){ used[x] = 1; for (auto [w, v] : adj[x]) dist[v] = min(dist[v], dist[x] + w); } int Node, cnt, X, op, Y; void Send(){ Y = inf; bool ok = false; for (int u = 0; u < n; ++ u) if (!used[u]){ ok = true; if (dist[u] < Y) Y = dist[u], Node = u; } if (!ok) return; op = 1; Y -= D; Y = min(Y, MaxE); for (int i = L - 1; i >= 0; -- i) SendB(Y >> i & 1); } void InitB(int NN, int B, vi U, vi V, vi C){ n = NN, m = B; for (int i = 0; i < B; ++ i) { adj[U[i]].pb({C[i], V[i]}); adj[V[i]].pb({C[i], U[i]}); } dist.resize(n, inf); used.resize(n, 0); dist[0] = 0; D = 0; upd(0); Send(); } void ReceiveB(bool y){ X = X * 2 + y; ++ cnt; if (op == 1){ if (cnt == L){ if (Y < X){ for (int i = 10; i >= 0; -- i) SendB(Node >> i & 1); D += Y; upd(Node); Send(); cnt = 0, X = 0; } else { D += X; op = 2; cnt = 0; X = 0; } } } else if (op == 2){ if (cnt == 11){ dist[X] = D; upd(X); Send(); cnt = 0; X = 0; } } }

Compilation message (stderr)

Azer.cpp: In function 'void Send()':
Azer.cpp:31:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   31 |     if (!ok) return; op = 1;
      |     ^~
Azer.cpp:31:22: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   31 |     if (!ok) return; op = 1;
      |                      ^~

Baijan.cpp: In function 'void Send()':
Baijan.cpp:31:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   31 |     if (!ok) return; op = 1;
      |     ^~
Baijan.cpp:31:22: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   31 |     if (!ok) return; op = 1;
      |                      ^~
#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...