Submission #985755

#TimeUsernameProblemLanguageResultExecution timeMemory
985755SzymonKrzywdaTwo Transportations (JOI19_transportations)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "Azer.h" using namespace std; const int BITS = 20; int poczatek = 0; int liczba_w; int akt = 0; int akt_2 = 0; string akt_str = ""; vector<int> answer={}; int info[3]; vector<vector<pair<int,int>>> graf(500000); void dijkstra(){ int val,v; priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>pq; pq.push({0,0}); while (!pq.empty()){ val = pq.top().first; v = pq.top().second; pq.pop(); if (val >= answer[v]) continue; answer[v] = val; for (auto [b,val_2] : graf[v]){ pq.push({val+val_2,b}); } } } string decToBinary(int n) { string ans = ""; for (int i = BITS; i >= 0; i--) { int k = n >> i; if (k & 1) ans += "1"; else ans += "0"; } return ans; } int binaryToDecimal(string str) { int dec_num = 0; int power = 0 ; int n = str.length() ; for(int i = n-1 ; i>=0 ; i--){ if(str[i] == '1'){ dec_num += (1<<power) ; } power++ ; } return dec_num; } vector<int> Answer(); void ReceiveA(bool x){ if (x == 0) akt_str += "0"; else akt_str += "1"; if (akt_2==BITS){ int liczba = binaryToDecimal(akt_str); if (poczatek==0){ liczba_w = liczba; } else{ if (akt==0){ // wierzcholek 1 info[0] = liczba; } else if (akt==1){// wierzcholek 2 info[1] = liczba; } else{ // waga graf[info[0]].push_back({info[1],liczba}); poczatek += 1; if (poczatek==liczba_w){ dijkstra(); } } akt_2 = 0; akt = (akt+1)%3 } } else akt_2 += 1; } void SendA(bool y); void send(int a){ string bin = decToBinary(a); for (int i=0; i<LOG+1; i++){ SendA(bin[i]); } } void InitA(int N, int A, vector<int> U, vector<int> V, vector<int> C){ for (int i=0; i<N; i++){ answer.push_back(9999999); } for (int i=0; i<A; i++){ graf[U[i]].push_back({V[i],C[i]}); } }
#include <bits/stdc++.h> #include "Baijan.h" using namespace std; const int BITS = 20; string decToBinary(int n) { string ans = ""; for (int i = BITS; i >= 0; i--) { int k = n >> i; if (k & 1) ans += "1"; else ans += "0"; } } void ReceiveB(bool y){ } void SendB(bool x); int send(int a){ string bin = decToBinary(a); for (int i=0; i<LOG+1; i++){ SendB(bin[i]); } } void InitB(int N, int B, std::vector<int> S, std::vector<int> T, std::vector<int> D){ for (int i=0; i<B; i++){ send(S[i]); send(T[i]); send(D[i]); } }

Compilation message (stderr)

Azer.cpp: In function 'void ReceiveA(bool)':
Azer.cpp:89:28: error: expected ';' before '}' token
   89 |             akt = (akt+1)%3
      |                            ^
      |                            ;
   90 |         }
      |         ~                   
Azer.cpp: In function 'void send(int)':
Azer.cpp:99:21: error: 'LOG' was not declared in this scope
   99 |     for (int i=0; i<LOG+1; i++){
      |                     ^~~

Baijan.cpp: In function 'std::string decToBinary(int)':
Baijan.cpp:17:1: warning: no return statement in function returning non-void [-Wreturn-type]
   17 | }
      | ^
Baijan.cpp: In function 'int send(int)':
Baijan.cpp:28:21: error: 'LOG' was not declared in this scope
   28 |     for (int i=0; i<LOG+1; i++){
      |                     ^~~
Baijan.cpp:31:1: warning: no return statement in function returning non-void [-Wreturn-type]
   31 | }
      | ^