Submission #133591

#TimeUsernameProblemLanguageResultExecution timeMemory
133591mohammedehab2002Two Transportations (JOI19_transportations)C++14
62 / 100
1772 ms85280 KiB
#include "Azer.h" #include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int cura,nodea,statea; vector<int> dista,da; vector<pair<int,int> > va[2005]; set<pair<int,int> > sa; void upda(int node) { sa.erase({dista[node],node}); dista[node]=cura; for (auto p:va[node]) { if (cura+p.second<dista[p.first]) { sa.erase({dista[p.first],p.first}); dista[p.first]=cura+p.second; sa.insert({dista[p.first],p.first}); } } if (sa.empty()) return; nodea=sa.begin()->second; int rnd=uniform_int_distribution<int>(0,1)(rng); SendA(rnd); if (rnd) { statea=2; for (int i=0;i<11;i++) SendA(nodea&(1<<i)); for (int i=0;i<9;i++) SendA(min(dista[nodea]-cura,511)&(1<<i)); } else statea=1; } void InitA(int n,int a,vector<int> u,vector<int> v,vector<int> c) { for (int i=0;i<a;i++) { va[u[i]].push_back({v[i],c[i]}); va[v[i]].push_back({u[i],c[i]}); } for (int i=0;i<n;i++) { dista.push_back(1e9); sa.insert({dista[i],i}); } upda(0); } void ReceiveA(bool x) { if (statea==2) { if (x) { cura=dista[nodea]; upda(nodea); } else { statea=1; SendA(0); } return; } da.push_back(x); if (da.size()==20) { int node=0,add=0; for (int i=0;i<11;i++) node|=(da[i]<<i); for (int i=0;i<9;i++) add|=(da[i+11]<<i); da.clear(); if (dista[nodea]<cura+add) { SendA(0); SendA(1); statea=2; for (int i=0;i<11;i++) SendA(nodea&(1<<i)); for (int i=0;i<9;i++) SendA(min(dista[nodea]-cura,511)&(1<<i)); } else { cura+=add; SendA(1); upda(node); } } } vector<int> Answer() { return dista; }
#include "Baijan.h" #include <bits/stdc++.h> using namespace std; int curb,nodeb,stateb; vector<int> distb,db; vector<pair<int,int> > vb[2005]; set<pair<int,int> > sb; void updb(int node) { sb.erase({distb[node],node}); distb[node]=curb; for (auto p:vb[node]) { if (curb+p.second<distb[p.first]) { sb.erase({distb[p.first],p.first}); distb[p.first]=curb+p.second; sb.insert({distb[p.first],p.first}); } } if (sb.empty()) return; nodeb=sb.begin()->second; } void InitB(int n,int b,vector<int> u,vector<int> v,vector<int> c) { for (int i=0;i<b;i++) { vb[u[i]].push_back({v[i],c[i]}); vb[v[i]].push_back({u[i],c[i]}); } for (int i=0;i<n;i++) { distb.push_back(1e9); sb.insert({distb[i],i}); } updb(0); } void ReceiveB(bool x) { if (!stateb) { if (!x) { stateb=2; for (int i=0;i<11;i++) SendB(nodeb&(1<<i)); for (int i=0;i<9;i++) SendB(min(distb[nodeb]-curb,511)&(1<<i)); } else stateb=1; return; } if (stateb==2) { stateb=0; if (x) { curb=distb[nodeb]; updb(nodeb); } return; } db.push_back(x); if (db.size()==20) { int node=0,add=0; for (int i=0;i<11;i++) node|=(db[i]<<i); for (int i=0;i<9;i++) add|=(db[i+11]<<i); db.clear(); stateb=0; if (distb[nodeb]<=curb+add) SendB(0); else { curb+=add; SendB(1); updb(node); } } }
#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...