제출 #472405

#제출 시각아이디문제언어결과실행 시간메모리
472405flappybirdTwo Transportations (JOI19_transportations)C++14
100 / 100
1004 ms61220 KiB
#include "Azer.h" #include <bits/stdc++.h> using namespace std; typedef int ll; namespace { ll N, A; vector<ll> dis, chk; vector<ll> U, V, C; ll cnt = 0; ll c, v; ll pmv; ll pmn; ll pv; ll res; ll mode = 0; ll mv; ll val; pair<ll, ll> ppv = { 0, -1000 }; priority_queue<pair<ll, ll>> pq; vector<vector<pair<ll, ll>>> adj; void send(ll, ll); void func(); void send(ll x, ll a) { ll i; for (i = a - 1; i >= 0; i--) SendA(x & (1 << i)); } void func() { ll i; ll asdfsdf = 1; for (i = 1; i < N; i++) if (!chk[i]) asdfsdf = 0; if (asdfsdf) return; ll mn = 101010; mv = -1; pair<ll, ll> t; while (pq.size()) { t = pq.top(); pq.pop(); if (t.second == -1000) continue; if (chk[t.second]) continue; mv = t.second; break; } ppv = t; if (mv == -1) val = 511; else val = -t.first - pv; send(val, 9); } } // namespace void ReceiveA(bool x) { res *= 2; if (x) res++; cnt++; if (mode == 0) { if (cnt == 9) { cnt = 0; if (val <= res) { send(mv, 11); dis[mv] = val + pv; pv = dis[mv]; chk[mv] = 1; res = 0; for (auto x : adj[mv]) { if (chk[x.first]) continue; pq.emplace(-(x.second + dis[mv]), x.first); } func(); } else mode = 1, val = res, res = 0, pq.push(ppv), ppv = { 0, -1000 }; } } else { if (cnt == 11) { dis[res] = val + pv; pv = dis[res]; chk[res] = 1; cnt = 0; mode = 0; for (auto x : adj[res]) { if (chk[x.first]) continue; pq.emplace(-(x.second + dis[res]), x.first); } res = 0; func(); } } } std::vector<int> Answer() { return dis; } void InitA(int _N, int _A, vector<ll> _U, vector<ll> _V, vector<ll> _C) { tie(N, A, U, V, C) = make_tuple(_N, _A, _U, _V, _C); dis.resize(N); chk.resize(N); ll i; for (i = 1; i < N; i++) dis[i] = 1010101010; chk[0] = 1; mode = 0; res = 0; adj.resize(N); for (i = 0; i < A; i++) adj[U[i]].emplace_back(V[i], C[i]), adj[V[i]].emplace_back(U[i], C[i]); for (i = 0; i < adj[0].size(); i++) pq.emplace(-adj[0][i].second, adj[0][i].first); func(); }
#include "Baijan.h" #include <bits/stdc++.h> using namespace std; typedef int ll; namespace { ll N, B; ll cnt = 0; vector<ll> S, T, D; ll res = 0; ll pv = 0; ll mode; vector<ll> chk; vector<ll> dis; ll val; ll mv; pair<ll, ll> ppv = { 0, -1000 }; priority_queue<pair<ll, ll>> pq; vector<vector<pair<ll, ll>>> adj; void send(ll x, ll a) { ll i; for (i = a - 1; i >= 0; i--) SendB(x & (1 << i)); } void func() { ll i; ll mn = 511; mv = -1; pair<ll, ll> t; while (pq.size()) { t = pq.top(); pq.pop(); if (t.second == -1000) continue; if (chk[t.second]) continue; mv = t.second; break; } ppv = t; if (mv == -1) val = 511; else val = min(511, -t.first - pv); } } // namespace void InitB(int _N, int _B, vector<int> _S, vector<int> _T, vector<int> _D) { tie(N, B, S, T, D) = make_tuple(_N, _B, _S, _T, _D); ll i; dis.resize(N); chk.resize(N); for (i = 1; i < N; i++) dis[i] = 1010101010; chk[0] = 1; mode = 0; res = 0; adj.resize(N); for (i = 0; i < B; i++) adj[S[i]].emplace_back(T[i], D[i]), adj[T[i]].emplace_back(S[i], D[i]); for (i = 0; i < adj[0].size(); i++) pq.emplace(-adj[0][i].second, adj[0][i].first); } void ReceiveB(bool y) { res *= 2; if (y) res++; cnt++; if (!mode) { if (cnt == 9) { func(); send(val, 9); cnt = 0; if (val < res) { send(mv, 11); dis[mv] = pv + val; pv = dis[mv]; chk[mv] = 1; res = 0; for (auto x : adj[mv]) { if (chk[x.first]) continue; pq.emplace(-(x.second + dis[mv]), x.first); } } else mode = 1, val = res, res = 0, pq.push(ppv), ppv = { 0, -1000 }; } } else { if (cnt == 11) { cnt = 0; dis[res] = val + pv; pv = dis[res]; chk[res] = 1; mode = 0; for (auto x : adj[res]) { if (chk[x.first]) continue; pq.emplace(-(x.second + dis[res]), x.first); } res = 0; } } }

컴파일 시 표준 에러 (stderr) 메시지

Azer.cpp: In function 'void {anonymous}::func()':
Azer.cpp:35:6: warning: unused variable 'mn' [-Wunused-variable]
   35 |   ll mn = 101010;
      |      ^~
Azer.cpp: In function 'void InitA(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
Azer.cpp:109:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  109 |  for (i = 0; i < adj[0].size(); i++) pq.emplace(-adj[0][i].second, adj[0][i].first);
      |              ~~^~~~~~~~~~~~~~~
Azer.cpp: At global scope:
Azer.cpp:13:5: warning: '{anonymous}::pmn' defined but not used [-Wunused-variable]
   13 |  ll pmn;
      |     ^~~
Azer.cpp:12:5: warning: '{anonymous}::pmv' defined but not used [-Wunused-variable]
   12 |  ll pmv;
      |     ^~~
Azer.cpp:11:8: warning: '{anonymous}::v' defined but not used [-Wunused-variable]
   11 |  ll c, v;
      |        ^
Azer.cpp:11:5: warning: '{anonymous}::c' defined but not used [-Wunused-variable]
   11 |  ll c, v;
      |     ^

Baijan.cpp: In function 'void {anonymous}::func()':
Baijan.cpp:27:6: warning: unused variable 'i' [-Wunused-variable]
   27 |   ll i;
      |      ^
Baijan.cpp:28:6: warning: unused variable 'mn' [-Wunused-variable]
   28 |   ll mn = 511;
      |      ^~
Baijan.cpp: In function 'void InitB(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
Baijan.cpp:56:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |  for (i = 0; i < adj[0].size(); i++) pq.emplace(-adj[0][i].second, adj[0][i].first);
      |              ~~^~~~~~~~~~~~~~~
#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...