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;
#define s second
#define f first
namespace{
const int mxn=2005;
int n;
vector<pair<int,int>> adj[mxn];
vector<int> d(mxn,1e9);
int tmp=0;
int a,b=0;
int bit=0;
int cur=0;
int u,v,c;
}
void InitA(int N, int A, std::vector<int> U, std::vector<int> V,
std::vector<int> C) {
n=N;
a=A;
for(int i=0;i<A;i++){
adj[U[i]].push_back({V[i],C[i]});
adj[V[i]].push_back({U[i],C[i]});
}
}
void ReceiveA(bool x) {
if(tmp==0){
if(bit<11){
if(x) b+=(1<<bit);
bit++;
return;
}
}
if(tmp==0){
bit=0;
tmp=1;
//cout<<b<<'\n';
}
if(b>0){
//cout<<b<<' '<<tmp<<' '<<bit<<'\n';
if(tmp==1 and bit<11){
if(x) cur+=(1<<bit);
bit++;
return;
}
if(tmp==1){
u=cur;
bit=cur=0;
tmp=2;
}
if(tmp==2 and bit<11){
if(x) cur+=(1<<bit);
bit++;
return;
}
if(tmp==2){
v=cur;
bit=cur=0;
tmp=3;
}
if(tmp==3 and bit<9){
if(x) cur+=(1<<bit);
bit++;
if(bit==9){
c=cur;
bit=cur=0;
tmp=1;
//cout<<u<<' '<<v<<' '<<c<<'\n';
adj[u].push_back({v,c});
adj[v].push_back({u,c});
b--;
if(b>=1){
return;
}
}
else{
return;
}
}
}
if(b==0){
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;
d[0]=0;
pq.push({0,0});
while(!pq.empty()){
auto v=pq.top();
pq.pop();
if(d[v.s]!=v.f) continue;
for(auto u:adj[v.s]){
if(d[u.f]>d[v.s]+u.s){
d[u.f]=d[v.s]+u.s;
pq.push({d[u.f],u.f});
}
}
}
}
}
std::vector<int> Answer() {
vector<int> ans(n);
for(int i=0;i<n;i++){
ans[i]=d[i];
}
return ans;
}
#include "Baijan.h"
#include <bits/stdc++.h>
using namespace std;
#define s second
#define f first
namespace{
const int mxn=2005;
int n;
vector<pair<int,int>> adj[mxn];
int tmp=0;
int a,b=0;
int bit=0;
int cur=0;
int u,v,c;
}
void InitB(int N, int B, std::vector<int> S, std::vector<int> T,
std::vector<int> D) {
n=N;
b=B;
for(int i=0;i<B;i++){
adj[S[i]].push_back({T[i],D[i]});
//adj[V[i]].push_back({U[i],C[i]});
}
for(int i=0;i<11;i++){
if(b&(1<<i)) SendB(1);
else SendB(0);
}
for(int i=0;i<n;i++){
for(auto v:adj[i]){
for(int j=0;j<11;j++){
if(i&(1<<j)) SendB(1);
else SendB(0);
}
for(int j=0;j<11;j++){
if(v.f&(1<<j)) SendB(1);
else SendB(0);
}
for(int j=0;j<9;j++){
if(v.s&(1<<j)) SendB(1);
else SendB(0);
}
}
}
}
void ReceiveB(bool y) {
/*for(int i=0;i<n;i++){
for(auto v:adj[i]){
for(int j=0;j<11;j++){
if(i&(1<<j)) SendB(1);
else SendB(0);
}
for(int j=0;j<11;j++){
if(v.f&(1<<j)) SendB(1);
else SendB(0);
}
for(int j=0;j<9;j++){
if(v.s&(1<<j)) SendB(1);
else SendB(0);
}
}
}*/
}
Compilation message (stderr)
Baijan.cpp:15:9: warning: '{anonymous}::c' defined but not used [-Wunused-variable]
15 | int u,v,c;
| ^
Baijan.cpp:15:7: warning: '{anonymous}::v' defined but not used [-Wunused-variable]
15 | int u,v,c;
| ^
Baijan.cpp:15:5: warning: '{anonymous}::u' defined but not used [-Wunused-variable]
15 | int u,v,c;
| ^
Baijan.cpp:14:5: warning: '{anonymous}::cur' defined but not used [-Wunused-variable]
14 | int cur=0;
| ^~~
Baijan.cpp:13:5: warning: '{anonymous}::bit' defined but not used [-Wunused-variable]
13 | int bit=0;
| ^~~
Baijan.cpp:12:5: warning: '{anonymous}::a' defined but not used [-Wunused-variable]
12 | int a,b=0;
| ^
Baijan.cpp:11:5: warning: '{anonymous}::tmp' defined but not used [-Wunused-variable]
11 | int tmp=0;
| ^~~
# | 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... |