Submission #535798

#TimeUsernameProblemLanguageResultExecution timeMemory
535798tost_one_loveTwo Transportations (JOI19_transportations)C++17
Compilation error
0 ms0 KiB
#include "Azer.h" #include <vector> #include <iostream> using namespace std; #define ll long long #define maxn 2005 #define pii pair<int, int> #define ff first #define ss second #define uw ll namespace { #ifdef zisk void debug(){cout << endl;} template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);} template<class T> void pary(T l, T r) { while (l != r) cout << *l << " ", l++; cout << endl; } #else #define debug(...) 0 #define pary(...) 0 #endif const int inf = (1LL<<28) - 1; const int wbit = 9, nbit = 11; int N; int done = 0; int dis[maxn]; bool vis[maxn]; vector<pii> adj[maxn]; vector<bool> buf; int wait = 0; //0:weight, 1:node int cur = 0, bind = 0, bval = 0; int uind = 0, uval = 0; void send_weight(int w) { if (w >= (1<<wbit)) w = (1<<wbit) - 1; for (int i = 0;i < wbit;i++) { SendA(w & (1<<i)); } } void send_node(int id) { for (int i = 0;i < nbit;i++) { SendA(id & (1<<i)); } } int getnum() { int siz = 1; if (wait == 0) siz = wbit; else if (wait == 1) siz = nbit; int ret = 0; for (int i = 0;i < siz;i++) { ret = ret+ (buf[i] ? 1<<i : 0); } buf.erase(buf.begin(), buf.begin() + siz); return ret; } void get_best() { int best = inf; bind = 0; for (int j = 0;j < N;j++) { if (!vis[j] && dis[j] < best) { best = dis[j]; bind = j; } } wait = 0; bval = best - cur; send_weight(best - cur); } void solve() { if (wait == 0 && buf.size() >= wbit) { uval = getnum(); if (bval <= uval) { for (auto [v, e]:adj[bind]) { if (dis[bind] + e < dis[v]) { dis[v] = dis[bind] + e; } } vis[bind] = 1; cur = dis[bind]; if (++done >= N) Answer(); else { send_node(bind); get_best(); } return; } wait = 1; solve(); } else if (wait == 1 && buf.size() >= nbit){ uind = getnum(); dis[uind] = uval + cur; vis[uind] = 1; for (auto [v, e]:adj[uind]) { if (dis[uind] + e < dis[v]) { dis[v] = dis[uind] + e; } } cur += uval; if (++done >= N) Answer(); else { get_best(); } } } } // namespace std::vector<int> Answer() { std::vector<int> ans(N); for (int k = 0; k < N; ++k) { ans[k] = dis[k]; } return ans; } void ReceiveA(bool x) { buf.push_back(x); solve(); } void InitA(int N, int A, std::vector<int> U, std::vector<int> V, std::vector<int> C) { ::N = N; for (int i = 0; i < A; ++i) { adj[U[i]].push_back({V[i], C[i]}); adj[V[i]].push_back({U[i], C[i]}); } for (int i = 0;i < N;i++) dis[i] = inf, vis[i] = 0; dis[0] = 0; get_best(); }
#include "Baijan.h" #include <vector> #include <iostream> using namespace std; #define ll long long #define maxn 2005 #define pii pair<int, int> #define ff first #define ss second namespace { #ifdef zisk void debug(){cout << endl;} template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);} template<class T> void pary(T l, T r) { while (l != r) cout << *l << " ", l++; cout << endl; } #else #define debug(...) 0 #define pary(...) 0 #endif const int inf = (1LL<<28) - 1; const int wbit = 9, nbit = 11; int N; int done = 0; int dis[maxn]; bool vis[maxn]; vector<pii> adj[maxn]; vector<bool> buf; int wait = 0; //0:weight, 1:node int cur = 0, bind = 0, bval = 0; int uind = 0, uval = 0; void send_weight(int w) { if (w >= (1<<wbit)) w = (1<<wbit) - 1; for (int i = 0;i < wbit;i++) { SendA(w & (1<<i)); } } void send_node(int id) { for (int i = 0;i < nbit;i++) { SendA(id & (1<<i)); } } int getnum() { int siz = 1; if (wait == 0) siz = wbit; else if (wait == 1) siz = nbit; int ret = 0; for (int i = 0;i < siz;i++) { ret = ret+ (buf[i] ? 1<<i : 0); } buf.erase(buf.begin(), buf.begin() + siz); return ret; } void get_best() { int best = inf; bind = 0; for (int j = 0;j < N;j++) { if (!vis[j] && dis[j] < best) { best = dis[j]; bind = j; } } wait = 0; bval = best - cur; send_weight(best - cur); } void solve() { if (wait == 0 && buf.size() >= wbit) { uval = getnum(); if (bval <= uval) { for (auto [v, e]:adj[bind]) { if (dis[bind] + e < dis[v]) { dis[v] = dis[bind] + e; } } vis[bind] = 1; cur = dis[bind]; if (++done >= N) Answer(); else { send_node(bind); get_best(); } return; } wait = 1; solve(); } else if (wait == 1 && buf.size() >= nbit){ uind = getnum(); dis[uind] = uval + cur; vis[uind] = 1; for (auto [v, e]:adj[uind]) { if (dis[uind] + e < dis[v]) { dis[v] = dis[uind] + e; } } cur += uval; if (++done >= N) Answer(); else { get_best(); } } } } // namespace std::vector<int> Answer() { std::vector<int> ans(N); for (int k = 0; k < N; ++k) { ans[k] = dis[k]; } return ans; } void ReceiveA(bool x) { buf.push_back(x); solve(); } void InitA(int N, int A, std::vector<int> U, std::vector<int> V, std::vector<int> C) { ::N = N; for (int i = 0; i < A; ++i) { adj[U[i]].push_back({V[i], C[i]}); adj[V[i]].push_back({U[i], C[i]}); } for (int i = 0;i < N;i++) dis[i] = inf, vis[i] = 0; dis[0] = 0; get_best(); }

Compilation message (stderr)

Baijan.cpp: In function 'void {anonymous}::send_weight(int)':
Baijan.cpp:43:3: error: 'SendA' was not declared in this scope; did you mean 'SendB'?
   43 |   SendA(w & (1<<i));
      |   ^~~~~
      |   SendB
Baijan.cpp: In function 'void {anonymous}::send_node(int)':
Baijan.cpp:48:3: error: 'SendA' was not declared in this scope; did you mean 'SendB'?
   48 |   SendA(id & (1<<i));
      |   ^~~~~
      |   SendB
Baijan.cpp: In function 'void {anonymous}::solve()':
Baijan.cpp:87:21: error: 'Answer' was not declared in this scope
   87 |    if (++done >= N) Answer();
      |                     ^~~~~~
Baijan.cpp:106:20: error: 'Answer' was not declared in this scope
  106 |   if (++done >= N) Answer();
      |                    ^~~~~~