Submission #754697

#TimeUsernameProblemLanguageResultExecution timeMemory
754697PiokemonTwo Transportations (JOI19_transportations)C++17
0 / 100
4 ms784 KiB
#include <bits/stdc++.h> #include "Azer.h" using namespace std; typedef long long int ll; namespace { int n; vector<pair<int,int>> graf[2009]; priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> djikstra; int poprz=0; int dst[2009]; int wczyt=0,ter=0,o; pair<int,int> cel; void napisz(int x){ for (int i=0;i<11;i++) SendA(x & (1<<i)); } void nast(int v, int d){ dst[v] = d; poprz = d; for (pair<int,int> x:graf[v]){ if (dst[x.first] > d+x.second){ dst[x.first] = d+x.second; djikstra.push({x.first,dst[x.first]}); } } while(!djikstra.empty() && dst[djikstra.top().second] < djikstra.top().first) djikstra.pop(); if (djikstra.empty()) djikstra.push({1<<11-1,1}); napisz(djikstra.top().first-poprz); o = true; } } // namespace void InitA(int N, int A, vector<int> U, vector<int> V, vector<int> C) { n = N; for (int x=0;x<A;x++){ graf[U[x]].push_back({V[x],C[x]}); graf[V[x]].push_back({U[x],C[x]}); } for (int x=0;x<=n;x++) dst[x] = 1e9+9; nast(0,0); } void ReceiveA(bool x) { wczyt += (1<<ter) * x; ter++; if (ter==11){ while(!djikstra.empty() && dst[djikstra.top().second] < djikstra.top().first) djikstra.pop(); if (djikstra.empty()) djikstra.push({1<<11-1,1}); ter = 0; if (o){ cel.first = min(wczyt,djikstra.top().first-poprz)+poprz; if (wczyt == djikstra.top().first && djikstra.top().first == 2^11-1) return; if (wczyt >= djikstra.top().first){ napisz(djikstra.top().second); cel.second = djikstra.top().second; djikstra.pop(); nast(cel.first,cel.second); } } else{ cel.second = wczyt; djikstra.pop(); nast(cel.first,cel.second); } wczyt = 0; } } vector<int> Answer() { vector<int> odp; for (int x=0;x<n;x++) odp.push_back(dst[x]); return odp; }
#include <bits/stdc++.h> #include "Baijan.h" using namespace std; typedef long long int ll; namespace { int n; vector<pair<int,int>> graf[2009]; priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> djikstra; int poprz=0; int dst[2009]; int wczyt=0,ter=0,o; pair<int,int> cel; void napisz(int x){ for (int i=0;i<11;i++) SendB(x & (1<<i)); } void nast(int v, int d){ dst[v] = d; poprz = d; for (pair<int,int> x:graf[v]){ if (dst[x.first] > d+x.second){ dst[x.first] = d+x.second; djikstra.push({x.first,dst[x.first]}); } } while(!djikstra.empty() && dst[djikstra.top().second] < djikstra.top().first) djikstra.pop(); if (djikstra.empty()) djikstra.push({1<<11-1,1}); napisz(djikstra.top().first-poprz); o = true; } } // namespace void InitB(int N, int B, vector<int> S, vector<int> T, vector<int> D) { n = N; for (int x=0;x<B;x++){ graf[T[x]].push_back({S[x],D[x]}); graf[S[x]].push_back({T[x],D[x]}); } for (int x=0;x<=n;x++) dst[x] = 1e9+9; nast(0,0); } void ReceiveB(bool y) { wczyt += (1<<ter) * y; ter++; if (ter==11){ while(dst[djikstra.top().second] < djikstra.top().first) djikstra.pop();while(!djikstra.empty() && dst[djikstra.top().second] < djikstra.top().first) djikstra.pop(); if (djikstra.empty()) djikstra.push({1<<11-1,1}); ter = 0; if (o){ cel.first = min(wczyt,djikstra.top().first-poprz)+poprz; if (wczyt == djikstra.top().first && djikstra.top().first == 2^11-1) return; if (wczyt > djikstra.top().first){ napisz(djikstra.top().second); cel.second = djikstra.top().second; djikstra.pop(); nast(cel.first,cel.second); } } else{ cel.second = wczyt; djikstra.pop(); nast(cel.first,cel.second); } wczyt = 0; } }

Compilation message (stderr)

Azer.cpp: In function 'void {anonymous}::nast(int, int)':
Azer.cpp:29:47: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   29 |     if (djikstra.empty()) djikstra.push({1<<11-1,1});
      |                                             ~~^~
Azer.cpp: In function 'void ReceiveA(bool)':
Azer.cpp:53:51: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   53 |         if (djikstra.empty()) djikstra.push({1<<11-1,1});
      |                                                 ~~^~
Azer.cpp:57:78: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   57 |             if (wczyt == djikstra.top().first && djikstra.top().first == 2^11-1) return;
      |                                                                            ~~^~

Baijan.cpp: In function 'void {anonymous}::nast(int, int)':
Baijan.cpp:29:47: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   29 |     if (djikstra.empty()) djikstra.push({1<<11-1,1});
      |                                             ~~^~
Baijan.cpp: In function 'void ReceiveB(bool)':
Baijan.cpp:53:9: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   53 |         while(dst[djikstra.top().second] < djikstra.top().first) djikstra.pop();while(!djikstra.empty() && dst[djikstra.top().second] < djikstra.top().first) djikstra.pop();
      |         ^~~~~
Baijan.cpp:53:81: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
   53 |         while(dst[djikstra.top().second] < djikstra.top().first) djikstra.pop();while(!djikstra.empty() && dst[djikstra.top().second] < djikstra.top().first) djikstra.pop();
      |                                                                                 ^~~~~
Baijan.cpp:54:51: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   54 |         if (djikstra.empty()) djikstra.push({1<<11-1,1});
      |                                                 ~~^~
Baijan.cpp:58:78: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   58 |             if (wczyt == djikstra.top().first && djikstra.top().first == 2^11-1) return;
      |                                                                            ~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...