Submission #1097860

#TimeUsernameProblemLanguageResultExecution timeMemory
1097860thangdz2k7Two Transportations (JOI19_transportations)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #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; void Send(){ int 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; w = 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> #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; void Send(){ int 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 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; w = 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:30:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   30 |     if (!ok) return; op = 1;
      |     ^~
Azer.cpp:30:22: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   30 |     if (!ok) return; op = 1;
      |                      ^~
Azer.cpp: In function 'void InitA(int, int, vi, vi, vi)':
Azer.cpp:39:19: error: 'class std::vector<std::pair<int, int> >' has no member named 'pb'
   39 |         adj[U[i]].pb({C[i], V[i]});
      |                   ^~
Azer.cpp:40:19: error: 'class std::vector<std::pair<int, int> >' has no member named 'pb'
   40 |         adj[V[i]].pb({C[i], U[i]});
      |                   ^~
Azer.cpp: In function 'void ReceiveA(bool)':
Azer.cpp:50:17: error: 'Y' was not declared in this scope
   50 |             if (Y <= X){
      |                 ^
Azer.cpp:56:25: error: 'w' was not declared in this scope
   56 |                 D += X; w = 2; cnt = 0; X = 0;
      |                         ^

Baijan.cpp: In function 'void Send()':
Baijan.cpp:30:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   30 |     if (!ok) return; op = 1;
      |     ^~
Baijan.cpp:30:22: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   30 |     if (!ok) return; op = 1;
      |                      ^~
Baijan.cpp:32:39: error: 'SendA' was not declared in this scope; did you mean 'Send'?
   32 |     for (int i = L - 1; i >= 0; -- i) SendA(Y >> i & 1);
      |                                       ^~~~~
      |                                       Send
Baijan.cpp: In function 'void InitB(int, int, vi, vi, vi)':
Baijan.cpp:39:19: error: 'class std::vector<std::pair<int, int> >' has no member named 'pb'
   39 |         adj[U[i]].pb({C[i], V[i]});
      |                   ^~
Baijan.cpp:40:19: error: 'class std::vector<std::pair<int, int> >' has no member named 'pb'
   40 |         adj[V[i]].pb({C[i], U[i]});
      |                   ^~
Baijan.cpp: In function 'void ReceiveB(bool)':
Baijan.cpp:50:17: error: 'Y' was not declared in this scope
   50 |             if (Y < X){
      |                 ^
Baijan.cpp:55:25: error: 'w' was not declared in this scope
   55 |                 D += X; w = 2; cnt = 0; X = 0;
      |                         ^