Submission #259341

#TimeUsernameProblemLanguageResultExecution timeMemory
259341keko37Two Transportations (JOI19_transportations)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> //#include "Azer.h" using namespace std; typedef pair <int, int> pi; const int MAXN = 2005; int n, m, mx, ans, ex, tip, mn, ind, ost, role; vector <pi> v[MAXN]; int bio[MAXN], dist[MAXN]; void SendA (bool x) {} void SendNum (int val, int br) { for (int i = br - 1; i >= 0; i--) { SendA((bool) (val & (1 << i))); } } void update (int x, int d) { bio[x] = 1; dist[x] = d; mx = max(mx, dist[x]); for (auto par : v[x]) { int sus = par.first, w = par.second; if (bio[sus] == 0 && dist[x] + w < dist[sus]) dist[sus] = dist[x] + w; } } void solve () { if (ost == 0) return; if (tip == 0) { role = rand() % 2; SendNum(role, 1); tip = 1; solve(); } else if (role == 0) { if (tip == 1) { mn = 501, ind = -1; for (int j = 1; j <= n; j++) { if (bio[j] == 0 && dist[j] - mx < mn) { mn = dist[j] - mx; ind = j; } } SendNum(mn, 9); ans = 0; ex = 1; } else if (tip == 2) { if (ans == 0) { SendNum(ind, 11); tip = 5; solve(); } else { ans = 0; ex = 9; } } else if (tip == 3) { mn = ans; ans = 0; ex = 11; } else if (tip == 4) { ind = ans; tip = 5; solve(); } else if (tip == 5) { update(ind, mx + mn); tip = 0; ost--; solve(); } } else { if (tip == 1) { mn = 501, ind = -1; for (int j = 1; j <= n; j++) { if (bio[j] == 0 && dist[j] - mx < mn) { mn = dist[j] - mx; ind = j; } } ans = 0; ex = 9; } else if (tip == 2) { if (mn < ans) { SendNum(1, 1); SendNum(mn, 9); SendNum(ind, 11); tip = 4; solve(); } else { SendNum(0, 1); mn = ans; ans = 0; ex = 11; } } else if (tip == 3) { ind = ans; tip = 4; solve(); } else if (tip == 4) { update(ind, mx + mn); tip = 0; ost--; solve(); } } } void ReceiveA (bool x) { ans *= 2; if (x) ans++; ex--; if (ex == 0) { tip++; solve(); } } std::vector<int> Answer () { vector <int> res(n); for (int i = 0; i < n; i++) res[i] = dist[i]; return res; } void InitA (int N, int A, std::vector <int> U, std::vector <int> V, std::vector <int> C) { n = N; m = A; for (int i = 0; i < m; i++) { v[U[i]].push_back({V[i], C[i]}); v[V[i]].push_back({U[i], C[i]}); } for (int i = 1; i <= n; i++) dist[i] = 1e9; update(0, 0); ost = n-1; solve(); } int main () { return 0; }
#include<bits/stdc++.h> #include "Baijan.h" using namespace std; typedef pair <int, int> pi; const int MAXN = 2005; int n, m, mx, ans, ex, tip, mn, ind, ost; vector <pi> v[MAXN]; int bio[MAXN], dist[MAXN]; //void SendB (bool x) {} void SendNum (int val, int br) { for (int i = br - 1; i >= 0; i--) { SendB((bool) (val & (1 << i))); } } void update (int x, int d) { bio[x] = 1; dist[x] = d; mx = max(mx, dist[x]); for (auto par : v[x]) { int sus = par.first, w = par.second; if (bio[sus] == 0 && dist[x] + w < dist[sus]) dist[sus] = dist[x] + w; } } void solve () { if (ost == 0) return; if (tip == 0) { role = ans; tip = 1; solve(); } else if (role == 0) { if (tip == 1) { mn = 501, ind = -1; for (int j = 1; j <= n; j++) { if (bio[j] == 0 && dist[j] - mx < mn) { mn = dist[j] - mx; ind = j; } } SendNum(mn, 9); ans = 0; ex = 1; } else if (tip == 2) { if (ans == 0) { SendNum(ind, 11); tip = 5; solve(); } else { ans = 0; ex = 9; } } else if (tip == 3) { mn = ans; ans = 0; ex = 11; } else if (tip == 4) { ind = ans; tip = 5; solve(); } else if (tip == 5) { update(ind, mx + mn); tip = 0; ost--; solve(); } } else { if (tip == 1) { mn = 501, ind = -1; for (int j = 1; j <= n; j++) { if (bio[j] == 0 && dist[j] - mx < mn) { mn = dist[j] - mx; ind = j; } } ans = 0; ex = 9; } else if (tip == 2) { if (mn < ans) { SendNum(1, 1); SendNum(mn, 9); SendNum(ind, 11); tip = 4; solve(); } else { SendNum(0, 1); mn = ans; ans = 0; ex = 11; } } else if (tip == 3) { ind = ans; tip = 4; solve(); } else if (tip == 4) { update(ind, mx + mn); tip = 0; ost--; solve(); } } } void ReceiveB (bool x) { ans *= 2; if (x) ans++; ex--; if (ex == 0) { tip++; solve(); } } void InitB (int N, int B, std::vector <int> U, std::vector <int> V, std::vector <int> C) { n = N; m = B; for (int i = 0; i < m; i++) { v[U[i]].push_back({V[i], C[i]}); v[V[i]].push_back({U[i], C[i]}); } for (int i = 1; i <= n; i++) dist[i] = 1e9; update(0, 0); ost = n-1; solve(); } /*int main () { return 0; }*/

Compilation message (stderr)

/tmp/ccRhqhtI.o: In function `SendA(bool)':
grader_azer.cpp:(.text+0x0): multiple definition of `SendA(bool)'
/tmp/ccGm27iI.o:Azer.cpp:(.text+0x30): first defined here
/tmp/ccRhqhtI.o: In function `main':
grader_azer.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccGm27iI.o:Azer.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status

Baijan.cpp: In function 'void solve()':
Baijan.cpp:34:9: error: 'role' was not declared in this scope
         role = ans;
         ^~~~
Baijan.cpp:34:9: note: suggested alternative: 'solve'
         role = ans;
         ^~~~
         solve
Baijan.cpp:36:16: error: 'role' was not declared in this scope
     } else if (role == 0) {
                ^~~~
Baijan.cpp:36:16: note: suggested alternative: 'solve'
     } else if (role == 0) {
                ^~~~
                solve