Submission #1221491

#TimeUsernameProblemLanguageResultExecution timeMemory
1221491salmonTwo Transportations (JOI19_transportations)C++20
0 / 100
2 ms1052 KiB
#include "Azer.h" #include <bits/stdc++.h> using namespace std; namespace { int N; bool used[2100]; int d[2100]; int cont = 0; int big = 0; int it = 0; int v = 0; int inf = 1e9; vector<pair<int,int>> adjlst[2100]; void pack(int v, int n){ for(int i = 0; i < n; i++){ SendA((v&(1<<i))>0); } } } // namespace 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++){ adjlst[U[i]].push_back({V[i],C[i]}); adjlst[V[i]].push_back({U[i],C[i]}); } for(int i = 0; i < N; i++){ used[i] = false; d[i] = inf; } used[0] = true; d[0] = 0; pair<int,int> ii = {inf,-1}; for(int i = 0; i < N; i++) if(!used[i]) ii = min(ii,{d[i],i}); bool tell = true; if(cont != 0 && ii.first > v + big){ ii = {v + big, it}; tell = false; } d[ii.second] = ii.first; int package = ii.first - big; big = ii.first; int g = ii.second; for(pair<int,int> ii1 : adjlst[g]){ d[ii1.first] = min(d[ii1.first],d[g] + ii1.second); } used[g] = true; int num = big + 501; for(int i = 0; i < N; i++) if(!used[i]) num = min(num,d[i]); for(int i = 0; i < 9; i++){ SendA((num&(1<<i))>0); } if(tell){ for(int i = 0; i < 11; i++){ SendA((g&(1<<i))>0); } for(int i = 0; i < 9; i++){ SendA((package&(1<<i))>0); } } } void ReceiveA(bool x) { if(cont == 0) if(!x) cont = 20; if(cont < 12) if(x) it += (1<<(cont-1)); else if(x) v += (1<<(x-12)); if(cont == 20){ pair<int,int> ii = {inf,-1}; for(int i = 0; i < N; i++){ if(!used[i]) ii = min(ii,{d[i],i}); } bool tell = true; if(cont != 0 && ii.first > v + big){ ii = {v + big, it}; tell = false; } d[ii.second] = ii.first; big = ii.first; int g = ii.second; for(pair<int,int> ii : adjlst[g]){ d[ii.first] = min(d[ii.first],d[g] + ii.second); } used[g] = true; int num = big + 501; for(int i = 0; i < N; i++) if(!used[i]) num = min(num,d[i]); pack(num - big,9); if(tell){ pack(g,11); } cont = 0; it = 0; v = 0; return; } ++cont; } std::vector<int> Answer() { std::vector<int> ans(N); for (int k = 0; k < N; ++k) { ans[k] = d[k]; } return ans; }
#include "Baijan.h" #include <bits/stdc++.h> using namespace std; namespace { int N; bool used[2100]; int d[2100]; int cont = 0; int big = 0; int it = 0; int v = 0; int inf = 1e9; vector<pair<int,int>> adjlst[2100]; bool pastuse; int pastv; void pack(int v, int n){ for(int i = 0; i < n; i++){ SendB((v&(1<<i))>0); } } } // namespace void InitB(int N, int B, std::vector<int> S, std::vector<int> T, std::vector<int> D) { ::N = N; cont = 0; for(int i = 0; i < N; i++){ used[i] = false; d[i] = inf; } pastuse = false; pastv = 0; } void ReceiveB(bool y) { if(cont < 9) if(y) v += (1<<cont); if(cont < 20 && !pastuse) if(y) it += (1<<(cont-9)); if((cont == 8 && pastuse) || cont == 19){ if(!pastuse){ d[it] = pastv + big; used[it] = true; big = pastv + big; } pair<int,int> ii = {inf,-1}; for(int i = 0; i < N; i++){ if(!used[i]) ii = min(ii,{d[i],i}); } if(ii.first < v + big){ pastuse = true; SendB(true); d[ii.second] = ii.first; used[ii.second] = true; pack(ii.second,11); pack(ii.first - big,9); big = ii.first; } else{ pastuse = false; pastv = v; SendB(false); } cont = 0; it = 0; v = 0; return; } cont++; }
#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...