제출 #951003

#제출 시각아이디문제언어결과실행 시간메모리
951003hengliaoTwo Transportations (JOI19_transportations)C++14
62 / 100
954 ms59480 KiB
#include "Azer.h" #include <bits/stdc++.h> using namespace std; typedef int ll; #define pb push_back #define F first #define S second namespace { const ll inf=1e9; ll n; priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq; vector<ll> ans; vector<pair<ll, ll>> adj[2005]; ll cnt; ll rcnt; ll curidx; ll curdis; ll pre; void sendidx(ll tar){ for(ll i=10;i>=0;i--){ if(tar&(1LL<<i)){ SendA(1); } else{ SendA(0); } } } void senddis(ll tar){ for(ll i=8;i>=0;i--){ if(tar&(1LL<<i)){ SendA(1); } else{ SendA(0); } } } } // namespace void InitA(int N, int A, vector<int> U, vector<int> V, vector<int> C) { n=N; ans=vector<ll>(n, inf); for(ll i=0;i<A;i++){ adj[U[i]].pb({V[i], C[i]}); adj[V[i]].pb({U[i], C[i]}); } ans[0]=0; cnt=1; rcnt=0; curidx=0; curdis=0; pq.push({0, 0}); pre=0; for(auto it:adj[0]){ ll x=it.F; ll y=it.S; pq.push({y, x}); } /* pair<ll, ll> cur=pq.top(); sendidx(cur.F); senddis(cur.S); cnt++; */ } void ReceiveA(bool x) { if(rcnt<11){ curidx*=2; if(x) curidx++; } else{ curdis*=2; if(x) curdis++; } rcnt++; if(rcnt>=20){ rcnt=0; pq.push({curdis+pre, curidx}); //cerr<<"good "<<curdis+pre<<' '<<curidx<<'\n'; curidx=0; curdis=0; while(!pq.empty() && ans[pq.top().S]!=inf){ pq.pop(); } if(!pq.empty()){ pair<ll, ll> cur=pq.top(); ans[cur.S]=cur.F; cnt++; for(auto it:adj[cur.S]){ ll x=it.F; ll y=it.S; pq.push({y+ans[cur.S], x}); } sendidx(cur.S); senddis(cur.F-pre); pre=cur.F; } /*else if(cnt<n){ sendidx(0); senddis(255); }*/ } } vector<int> Answer() { return ans; }
#include "Baijan.h" #include <bits/stdc++.h> using namespace std; typedef int ll; #define pb push_back #define F first #define S second namespace { const ll inf=1e9; ll n; priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq; vector<ll> ans; vector<pair<ll, ll>> adj[2005]; ll cnt; ll rcnt; ll curidx; ll curdis; ll pre; void sendidx(ll tar){ for(ll i=10;i>=0;i--){ if(tar&(1LL<<i)){ SendB(1); } else{ SendB(0); } } } void senddis(ll tar){ for(ll i=8;i>=0;i--){ if(tar&(1LL<<i)){ SendB(1); } else{ SendB(0); } } } } // namespace void InitB(int N, int A, vector<int> U, vector<int> V, vector<int> C) { n=N; ans=vector<ll>(n, inf); for(ll i=0;i<A;i++){ adj[U[i]].pb({V[i], C[i]}); adj[V[i]].pb({U[i], C[i]}); } ans[0]=0; cnt=0; rcnt=0; curidx=0; curdis=0; //pq.push({0, 0}); pre=0; for(auto it:adj[0]){ ll x=it.F; ll y=it.S; pq.push({y, x}); } if(pq.empty()){ sendidx(0); senddis(511); return; } pair<ll, ll> cur=pq.top(); sendidx(cur.S); senddis(cur.F); cnt++; } void ReceiveB(bool x) { if(rcnt<11){ curidx*=2; if(x) curidx++; } else{ curdis*=2; if(x) curdis++; } rcnt++; if(rcnt>=20){ cnt++; rcnt=0; ans[curidx]=curdis+pre; pre=ans[curidx]; for(auto it:adj[curidx]){ ll x=it.F; ll y=it.S; pq.push({y+ans[curidx], x}); } curidx=0; curdis=0; while(!pq.empty() && ans[pq.top().S]!=inf){ pq.pop(); } if(!pq.empty()){ pair<ll, ll> cur=pq.top(); sendidx(cur.S); senddis(cur.F-pre); //pre=cur.F; } else{ sendidx(0); senddis(511); } } }
#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...