이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "Azer.h"
#pragma GCC optimize("Ofast")
#define AquA cin.tie(0);ios_base::sync_with_stdio(0);
#define fs first
#define sc second
#define p_q priority_queue
using namespace std;
namespace{
vector<vector<pair<int,int> > > gg;
int n,m;
vector<int> dis,vis;
void send(int a,int i){
i--;
for(;i>=0;i--){
SendA((a>>i)&1);
}
}
int nw=0,cnt=0,tp=0,x=0,pre=0;
}
void InitA(int N, int A, std::vector<int> U, std::vector<int> V, std::vector<int> C){
send(0,9);
n=N;
m=A;
gg.resize(n);
dis.resize(n,1e9);
vis.resize(n);
dis[0]=0;
for(int i=0;i<m;i++){
gg[U[i]].push_back({V[i],C[i]});
gg[V[i]].push_back({U[i],C[i]});
}
}
void ReceiveA(bool y){
nw=2*nw+y;
cnt++;
if(tp==0){
if(cnt==9){
if(nw<=x){
tp=1;
pre+=nw;
}
else{
nw=x;
pre+=nw;
for(int i=0;i<n;i++){
if(!vis[i] && dis[i]==pre){
send(i,11);
dis[i]=pre;
vis[i]=1;
for(auto h:gg[i]){
dis[h.fs]=min(dis[h.fs],dis[i]+h.sc);
}
int mm=1e9;
int uu=0;
for(int j=0;j<n;j++){
if(!vis[j] && dis[j]<mm){
mm=dis[j];
}
if(!vis[j]){
uu++;
}
}
if(!uu){
return;
}
x=min(511,mm-pre);
send(x,9);
break;
}
}
}
nw=0;
cnt=0;
}
}
else if(tp==1){
if(cnt==11){
dis[nw]=pre;
vis[nw]=1;
for(auto h:gg[nw]){
dis[h.fs]=min(dis[h.fs],dis[nw]+h.sc);
}
int mm=1e9;
int uu=0;
for(int i=0;i<n;i++){
if(!vis[i] && dis[i]<mm){
mm=dis[i];
}
if(!vis[i]){
uu++;
}
}
if(!uu){
return;
}
x=min(511,mm-pre);
send(x,9);
cnt=0;
nw=0;
tp=0;
}
}
}
std::vector<int> Answer(){
return dis;
}
#include <bits/stdc++.h>
#include "Baijan.h"
#pragma GCC optimize("Ofast")
#define AquA cin.tie(0);ios_base::sync_with_stdio(0);
#define fs first
#define sc second
#define p_q priority_queue
using namespace std;
namespace{
vector<vector<pair<int,int> > > gg;
int n,m;
vector<int> dis,vis;
void send(int a,int i){
i--;
for(;i>=0;i--){
SendB((a>>i)&1);
}
}
int nw=0,cnt=0,tp=0,x=0,pre=0;
int cz=0;
}
void InitB(int N, int B, std::vector<int> S, std::vector<int> T, std::vector<int> D){
send(0,9);
n=N;
m=B;
gg.resize(n);
dis.resize(n,1e9);
vis.resize(n);
dis[0]=0;
for(int i=0;i<m;i++){
gg[S[i]].push_back({T[i],D[i]});
gg[T[i]].push_back({S[i],D[i]});
}
}
void ReceiveB(bool y){
nw=2*nw+y;
cnt++;
if(tp==0){
if(cnt==9){
if(nw<x){
tp=1;
pre+=nw;
}
else{
nw=x;
pre+=nw;
for(int i=0;i<n;i++){
if(!vis[i] && dis[i]==pre){
send(i,11);
dis[i]=pre;
vis[i]=1;
for(auto h:gg[i]){
dis[h.fs]=min(dis[h.fs],dis[i]+h.sc);
}
int mm=1e9;
int uu=0;
for(int j=0;j<n;j++){
if(!vis[j] && dis[j]<mm){
mm=dis[j];
}
if(!vis[j]){
uu++;
}
}
if(!uu){
return;
}
x=min(511,mm-pre);
send(x,9);
break;
}
}
}
nw=0;
cnt=0;
}
}
else if(tp==1){
if(cnt==11){
dis[nw]=pre;
vis[nw]=1;
for(auto h:gg[nw]){
dis[h.fs]=min(dis[h.fs],dis[nw]+h.sc);
}
int mm=1e9;
int uu=0;
for(int i=0;i<n;i++){
if(!vis[i] && dis[i]<mm){
mm=dis[i];
}
if(!vis[i]){
uu++;
}
}
if(!uu){
return;
}
x=min(511,mm-pre);
send(x,9);
cnt=0;
nw=0;
tp=0;
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
Baijan.cpp:21:9: warning: '{anonymous}::cz' defined but not used [-Wunused-variable]
21 | int cz=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... |