Submission #900788

#TimeUsernameProblemLanguageResultExecution timeMemory
900788nguyentunglamTwo Transportations (JOI19_transportations)C++17
Compilation error
0 ms0 KiB
#include "Baijan.h" #include <vector> #include<bits/stdc++.h> using namespace std; const int M1 = 20, M2 = 11; namespace { const int N = 2e3 + 10; int n; int cnt; int d[N]; bool mark[N]; vector<pair<int, int> > adj[N]; #define ii pair<int, int> priority_queue<ii, vector<ii>, greater<ii> > q; void init () { for(int i = 1; i <= n; i++) d[i] = (1 << 30) - 1; for(auto &it : adj[0]) { int v, w; tie(v, w) = it; q.push({d[v] = w, v}); } } void add_edge (int u, int v, int w) { adj[u].emplace_back(v, w); adj[v].emplace_back(u, w); } pair<int, int> nxt; void add () { while (!q.empty() && mark[q.top().second]) q.pop(); if (q.empty()) { for(int i = 0; i < M1 + M2; i++) SendB(1); nxt = make_pair(1e9, 1e9); return; } int cost, u; tie(cost, u) = q.top(); nxt = make_pair(cost, u); // cout << cost << " " << u << "@" << endl; // for(int i = 0; i < M1; i++) cout << (cost >> i & 1); // for(int i = 0; i < M2; i++) cout << (u >> i & 1); // cout << "SendB\n"; for(int i = 0; i < M1; i++) SendB(cost >> i & 1); for(int i = 0; i < M2; i++) SendB(u >> i & 1); } void calc (int cost, int u) { mark[u] = 1; d[u] = cost; if (cost > 1e6) return; for(auto &it : adj[u]) { int v, w; tie(v, w) = it; if (d[v] > d[u] + w) q.push({d[v] = d[u] + w, v}); } // nxt = make_pair(1e9, 1e9); } } // namespace void InitB(int N, int B, std::vector<int> S, std::vector<int> T, std::vector<int> D) { ::n = N; for(int i = 0; i < B; i++) { ::add_edge(S[i], T[i], D[i]); } ::init(); } bool bitB[100]; int cntB; void ReceiveB(bool y) { bitB[cntB++] = y; if (cntB == M1 + M2) { int cost = 0, u = 0; for(int i = 0; i < M1; i++) if (bitB[i]) cost |= (1 << i); for(int i = M1; i < M1 + M2; i++) if (bitB[i]) u |= (1 << i - M1); // cout << cost << " " << u << endl; ::add(); nxt = min(nxt, make_pair(cost, u)); calc(nxt.first, nxt.second); cntB = 0; } }

Compilation message (stderr)

Azer.cpp: In function 'void {anonymous}::add()':
Azer.cpp:38:38: error: 'SendB' was not declared in this scope
   38 |     for(int i = 0; i < M1 + M2; i++) SendB(1);
      |                                      ^~~~~
Azer.cpp:48:31: error: 'SendB' was not declared in this scope
   48 |   for(int i = 0; i < M1; i++) SendB(cost >> i & 1);
      |                               ^~~~~
Azer.cpp:49:31: error: 'SendB' was not declared in this scope
   49 |   for(int i = 0; i < M2; i++) SendB(u >> i & 1);
      |                               ^~~~~
Azer.cpp: In function 'void ReceiveB(bool)':
Azer.cpp:84:65: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   84 |     for(int i = M1; i < M1 + M2; i++) if (bitB[i]) u |= (1 << i - M1);
      |                                                               ~~^~~~
Azer.cpp: At global scope:
Azer.cpp:12:5: warning: '{anonymous}::cnt' defined but not used [-Wunused-variable]
   12 | int cnt;
      |     ^~~

/usr/bin/ld: /tmp/ccJLsSyI.o: in function `main':
grader_baijan.cpp:(.text.startup+0x174): undefined reference to `InitB(int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
/usr/bin/ld: grader_baijan.cpp:(.text.startup+0x202): undefined reference to `ReceiveB(bool)'
collect2: error: ld returned 1 exit status