This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "Azer.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 2000;
const int MAXA = 6e5;
const int INF = 1e9;
struct Edge
{
int u, v, w;
};
static int N, A, B;
static Edge EA[MAXA+10], EB[MAXA+10];
static int ans[MAXN+10];
static vector<pii> adj[MAXN+10];
static int cnt=-10;
struct Queue
{
int u, w;
bool operator < (const Queue &p) const
{
return w>p.w;
}
};
static int dist[MAXN+10];
vector<int> Answer()
{
vector<int> ret=vector<int>(ans, ans+N);
return ret;
}
void InitA(int _N, int _A, vector<int> _U, vector<int> _V, vector<int> _C)
{
N=_N; A=_A;
for(int i=0; i<A; i++) EA[i]={_U[i], _V[i], _C[i]};
}
void dijk()
{
//printf("B : %d\n", B);
for(int i=0; i<A; i++)
{
int u=EA[i].u, v=EA[i].v, w=EA[i].w;
assert(u!=v); assert(w<=500);
adj[u].push_back({v, w});
adj[v].push_back({u, w});
}
for(int i=0; i<B; i++)
{
int u=EB[i].u, v=EB[i].v, w=EB[i].w;
assert(u!=v); assert(w<=500);
//printf("%d %d %d\n", u, v, w);
adj[u].push_back({v, w});
adj[v].push_back({u, w});
}
for(int i=0; i<N; i++) dist[i]=INF;
priority_queue<Queue> PQ;
PQ.push({0, 0});
while(!PQ.empty())
{
Queue now=PQ.top(); PQ.pop();
if(dist[now.u]<=now.w) continue;
//printf("%d %d\n", now.u, now.w);
dist[now.u]=now.w;
for(auto nxt : adj[now.u]) PQ.push({nxt.first, nxt.second+now.w});
}
for(int i=0; i<N; i++) ans[i]=dist[i];
}
void ReceiveA(bool x)
{
if(cnt<0)
{
if(x)
{
B|=(1<<(cnt+10));
}
if(cnt==-1 && B==0) dijk();
}
else
{
if(x)
{
int t=cnt%31;
if(t<11) EB[cnt/31].u|=(1<<t);
else if(t<22) EB[cnt/31].v|=(1<<(t-11));
else EB[cnt/31].w|=(1<<(t-22));
}
if(cnt==31*B-1) dijk();
}
cnt++;
}
#include "Baijan.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 2000;
const int MAXA = 5e5;
const int INF = 1e9;
struct Edge
{
int u, v, w;
};
static int N, B;
static Edge EA[MAXA+10], EB[MAXA+10];
static int ans[MAXN+10];
static vector<pii> adj[MAXN+10];
static int cnt=0;
void InitB(int _N, int _B, vector<int> _U, vector<int> _V, vector<int> _C)
{
N=_N; B=_B;
for(int i=0; i<B; i++) EB[i]={_U[i], _V[i], _C[i]};
for(int i=0; i<B; i++)
{
int u=EB[i].u, v=EB[i].v, w=EB[i].w;
adj[u].push_back({v, w});
adj[v].push_back({u, w});
}
assert(B<=1000);
for(int i=0; i<10; i++)
{
if(B&(1<<i)) SendB(1);
else SendB(0);
}
for(int i=0; i<B; i++)
{
for(int j=0; j<11; j++)
{
if(EB[i].u&(1<<j)) SendB(1);
else SendB(0);
}
for(int j=0; j<11; j++)
{
if(EB[i].v&(1<<j)) SendB(1);
else SendB(0);
}
for(int j=0; j<9; j++)
{
if(EB[i].w&(1<<j)) SendB(1);
else SendB(0);
}
}
}
void ReceiveB(bool x)
{
}
Compilation message (stderr)
Baijan.cpp:22:12: warning: 'cnt' defined but not used [-Wunused-variable]
22 | static int cnt=0;
| ^~~
Baijan.cpp:20:12: warning: 'ans' defined but not used [-Wunused-variable]
20 | static int ans[MAXN+10];
| ^~~
Baijan.cpp:19:13: warning: 'EA' defined but not used [-Wunused-variable]
19 | static Edge EA[MAXA+10], EB[MAXA+10];
| ^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |