제출 #720588

#제출 시각아이디문제언어결과실행 시간메모리
720588qwerasdfzxclTwo Transportations (JOI19_transportations)C++17
100 / 100
831 ms48972 KiB
#include "Azer.h" #include <bits/stdc++.h> constexpr int INF = 1e9 + 100; using namespace std; typedef long long ll; namespace { vector<pair<int, int>> adj[2020]; int n, dist[2020], visited[2020]; int mx, valA, valB, idxA, idxB, typ; vector<int> buf; } // namespace void updateA(int x, int v){ visited[x] = 1; dist[x] = mx + v; mx += v; for (auto &[nx, w]:adj[x]) dist[nx] = min(dist[nx], dist[x] + w); } 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]+1].emplace_back(V[i]+1, C[i]); adj[V[i]+1].emplace_back(U[i]+1, C[i]); } mx = 0, typ = 1; fill(dist+2, dist+n+1, INF); updateA(1, 0); } void cmpA(){ valA = INF, valB = 0; idxA = -1; for (int i=1;i<=n;i++) if (!visited[i] && valA > dist[i]) valA = dist[i], idxA = i; valA = min(valA-mx, 511); for (int i=0;i<9;i++) if (buf[i]) valB |= 1<<i; buf.clear(); for (int i=0;i<9;i++) SendA(valA&(1<<i)); if (valA <= valB){ for (int i=0;i<11;i++) SendA(idxA&(1<<i)); updateA(idxA, valA); } else{ typ = 2; } } void getA(){ idxB = 0; for (int i=0;i<11;i++) if (buf[i]) idxB |= 1<<i; buf.clear(); updateA(idxB, valB); typ = 1; } void ReceiveA(bool x) { buf.push_back(x); if (typ==1 && buf.size()==9) cmpA(); if (typ==2 && buf.size()==11) getA(); } std::vector<int> Answer() { vector<int> ans; for (int i=1;i<=n;i++) ans.push_back(dist[i]); return ans; }
#include "Baijan.h" #include <bits/stdc++.h> constexpr int INF = 1e9 + 100; using namespace std; typedef long long ll; namespace { vector<pair<int, int>> adj[2020]; int n, dist[2020], visited[2020]; int mx, valA, valB, idxA, idxB, typ; int cntB; vector<int> buf; } // namespace void updateB(int x, int v){ ++cntB; visited[x] = 1; dist[x] = mx + v; mx += v; for (auto &[nx, w]:adj[x]) dist[nx] = min(dist[nx], dist[x] + w); valB = INF, idxB = -1; for (int i=1;i<=n;i++) if (!visited[i] && valB > dist[i]) valB = dist[i], idxB = i; valB = min(valB-mx, 511); if (cntB==n) return; for (int i=0;i<9;i++) SendB(valB&(1<<i)); } void InitB(int N, int B, std::vector<int> S, std::vector<int> T, std::vector<int> D) { n = N; for (int i=0;i<B;i++){ adj[S[i]+1].emplace_back(T[i]+1, D[i]); adj[T[i]+1].emplace_back(S[i]+1, D[i]); } mx = 0, typ = 1; fill(dist+2, dist+n+1, INF); updateB(1, 0); } void checkB(){ valA = 0; for (int i=0;i<9;i++) if (buf[i]) valA |= 1<<i; buf.clear(); if (valA <= valB){ typ = 2; } else{ for (int i=0;i<11;i++) SendB(idxB&(1<<i)); updateB(idxB, valB); } } void getB(){ idxA = 0; for (int i=0;i<11;i++) if (buf[i]) idxA |= 1<<i; buf.clear(); updateB(idxA, valA); typ = 1; } void ReceiveB(bool y) { buf.push_back(y); if (typ==1 && buf.size()==9) checkB(); if (typ==2 && buf.size()==11) getB(); }
#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...