이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "Azer.h"
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
#define REP(i,j,k) for(int i=(j);i<(k);++i)
#define RREP(i,j,k) for(int i=int(j)-1;i>=(k);--i)
#define pb push_back
#define f first
#define s second
namespace{
const int maxn=2009,inf=1e9;
int n,ls=0,t=0,fin=0,r,tmp,d[maxn];
bitset<maxn>c;
vector<pii>g[maxn];
priority_queue<pii,vector<pii>,greater<pii>>pq;
void send(int x,int l){RREP(i,l,0)SendA((x>>i)&1);}
void rlx(int u,int x){
d[u]=x;
c[u]=1;
++fin;
ls=d[u];
REP(i,0,g[u].size()){
pii&ee=g[u][i];
if(d[u]+ee.s<d[ee.f]){
d[ee.f]=d[u]+ee.s;
pq.push({d[ee.f],ee.f});
}
}
}
void proc(){
if(t==0||t==21){
while(pq.size()&&c[pq.top().s])pq.pop();
send(pq.size()?pq.top().f-ls:511,9);
t=1;
}else if(t==9){
r+=ls;
if(pq.empty()||r<pq.top().f)tmp=r;
else{
pii tt=pq.top();pq.pop();
send(tt.s,11);
t+=11;
rlx(tt.s,tt.f);
}
}else rlx(r,tmp);
}
}
void InitA(int _n,int a,vector<int>u,vector<int>v,vector<int>c) {
n=_n;
REP(i,0,a)g[u[i]].pb({v[i],c[i]}),g[v[i]].pb({u[i],c[i]});
fill(d+1,d+n,inf);
pq.push({d[0],0});
proc();
}
void ReceiveA(bool x){
if(t==1||t==10)r=0;
(r<<=1)|=x;
if(t==9||t==20)proc();
++t;
if(t==21&&fin<n)proc();
}
vector<int>Answer(){
vector<int>ret;
REP(i,0,n)ret.pb(d[i]);
return ret;
}
#include "Baijan.h"
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
#define REP(i,j,k) for(int i=(j);i<(k);++i)
#define RREP(i,j,k) for(int i=int(j)-1;i>=(k);--i)
#define pb push_back
#define f first
#define s second
namespace{
const int maxn=2009,inf=1e9;
int n,ls=0,t=0,fin=0,r,tmp,d[maxn];
bitset<maxn>c;
vector<pii>g[maxn];
priority_queue<pii,vector<pii>,greater<pii>>pq;
void send(int x,int l){RREP(i,l,0)SendB((x>>i)&1);}
void rlx(int u,int x){
d[u]=x;
c[u]=1;
++fin;
ls=d[u];
REP(i,0,g[u].size()){
pii&ee=g[u][i];
if(d[u]+ee.s<d[ee.f]){
d[ee.f]=d[u]+ee.s;
pq.push({d[ee.f],ee.f});
}
}
}
void proc(){
if(t==0||t==21){
while(pq.size()&&c[pq.top().s])pq.pop();
send(pq.size()?pq.top().f-ls:511,9);
t=1;
}else if(t==9){
r+=ls;
if(pq.empty()||r<=pq.top().f)tmp=r;
else{
pii tt=pq.top();pq.pop();
send(tt.s,11);
t+=11;
rlx(tt.s,tt.f);
}
}else rlx(r,tmp);
}
}
void InitB(int _n,int a,vector<int>u,vector<int>v,vector<int>c) {
n=_n;
REP(i,0,a)g[u[i]].pb({v[i],c[i]}),g[v[i]].pb({u[i],c[i]});
fill(d+1,d+n,inf);
pq.push({d[0],0});
proc();
}
void ReceiveB(bool x){
if(t==1||t==10)r=0;
(r<<=1)|=x;
if(t==9||t==20)proc();
++t;
if(t==21&&fin<n)proc();
}
컴파일 시 표준 에러 (stderr) 메시지
Azer.cpp: In function 'void {anonymous}::rlx(int, int)':
Azer.cpp:5:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define REP(i,j,k) for(int i=(j);i<(k);++i)
^
Azer.cpp:24:3: note: in expansion of macro 'REP'
REP(i,0,g[u].size()){
^~~
Baijan.cpp: In function 'void {anonymous}::rlx(int, int)':
Baijan.cpp:5:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define REP(i,j,k) for(int i=(j);i<(k);++i)
^
Baijan.cpp:24:3: note: in expansion of macro 'REP'
REP(i,0,g[u].size()){
^~~
# | 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... |