QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#423882 | #67. Two Transportations | not_clever_sylQJ | Compile Error | / | / | C++20 | 5.7kb | 2024-05-28 18:47:51 | 2024-05-28 18:47:52 |
Judging History
Azer
#include"transportations.h"
#include<bits/stdc++.h>
using namespace std;
namespace my{
const int MAXN=2005;
void send_to(int x,bool v){
(x?SendA:SendB)(v);
}
struct machine{
int n;
int id;
struct edge{
int v,w;
};
vector<edge>e[MAXN];
inline void send(bool v){
send_to(!id,v);
}
inline void send_node(int u){
// if(id)cerr<<"\t\t";
// cerr<<id<<" send node "<<u<<'\n';
for(int i=10;i>=0;--i)send((u>>i)&1);
}
inline void send_w(int w){
// if(id)cerr<<"\t\t";
// cerr<<id<<" send edge "<<w<<'\n';
for(int i=8;i>=0;--i)send((w>>i)&1);
}
int nc,rv;
inline void receive(bool v){
rv=(rv<<1)|v;
--nc;
if(!nc){
// if(id)cerr<<"\t\t";
// cerr<<id<<" receive "<<rv<<'\n';
chk();
}
}
inline void build(int u,int v,int w){
e[u].emplace_back(edge{v,w});
e[v].emplace_back(edge{u,w});
}
int state;
int dis[MAXN];
bool vis[MAXN];
int u;
int last_w;
priority_queue<pair<int,int> >pq;
int myw,otherw;
void _chk(){
if(state==0){
state=1;
nc=0;
}
else if(state==1){
while(!pq.empty()&&vis[u=pq.top().second])pq.pop();
if(pq.empty()){
myw=506;
}
else{
myw=dis[u]-last_w;
}
send_w(myw);
state=2;
nc=9;
}
else if(state==2){
otherw=rv;
rv=0;
if(min(myw,otherw)>505){
state=-1;
nc=0;
return;
}
last_w+=min(myw,otherw);
if(
(otherw<myw)||(otherw==myw&&id==1)
){
state=3;
nc=11;
}
else{
send_node(u);
state=4;
nc=0;
}
}
else if(state==3){
u=rv;
rv=0;
dis[u]=last_w;
state=4;
nc=0;
}
else if(state==4){
vis[u]=true;
upd(u);
state=1;
nc=0;
}
}
void chk(){
while(!nc&&state!=-1)_chk();
}
void upd(int u){
for(auto it:e[u]){
if(!vis[it.v]&&dis[u]+it.w<dis[it.v]) {
dis[it.v]=dis[u]+it.w;
pq.push(make_pair(-dis[it.v],it.v));
}
}
}
inline void init(){
last_w=0;
memset(dis,0x3f,sizeof(dis));
dis[0]=0;
u=0;
upd(0);
state=1;
nc=0;
chk();
}
vector<int>answer(){
return vector<int>(dis,dis+n);
}
}a[2];
inline void receive(int x,bool v){
a[x].receive(v);
}
inline void init(int x,int n,int m,vector<int>u,vector<int>v,vector<int>w){
a[x].n=n;
a[x].id=x;
for(int i=0;i<m;++i)a[x].build(u[i],v[i],w[i]);
a[x].init();
}
};
std::vector<int>Answer(){
return my::a[0].answer();
}
void InitA(int N, int A, std::vector<int> U, std::vector<int> V, std::vector<int> C){
my::init(0,N,A,U,V,C);
}
void ReceiveA(bool x){
my::receive(0,x);
}
void InitB(int N, int B, std::vector<int> S, std::vector<int> T, std::vector<int> D){
my::init(1,N,B,S,T,D);
}
void ReceiveB(bool x){
my::receive(1,x);
}
Baijan
#include"transportations.h"
#include<bits/stdc++.h>
using namespace std;
namespace my{
const int MAXN=2005;
void send_to(int x,bool v){
(x?SendA:SendB)(v);
}
struct machine{
int n;
int id;
struct edge{
int v,w;
};
vector<edge>e[MAXN];
inline void send(bool v){
send_to(!id,v);
}
inline void send_node(int u){
// if(id)cerr<<"\t\t";
// cerr<<id<<" send node "<<u<<'\n';
for(int i=10;i>=0;--i)send((u>>i)&1);
}
inline void send_w(int w){
// if(id)cerr<<"\t\t";
// cerr<<id<<" send edge "<<w<<'\n';
for(int i=8;i>=0;--i)send((w>>i)&1);
}
int nc,rv;
inline void receive(bool v){
rv=(rv<<1)|v;
--nc;
if(!nc){
// if(id)cerr<<"\t\t";
// cerr<<id<<" receive "<<rv<<'\n';
chk();
}
}
inline void build(int u,int v,int w){
e[u].emplace_back(edge{v,w});
e[v].emplace_back(edge{u,w});
}
int state;
int dis[MAXN];
bool vis[MAXN];
int u;
int last_w;
priority_queue<pair<int,int> >pq;
int myw,otherw;
void _chk(){
if(state==0){
state=1;
nc=0;
}
else if(state==1){
while(!pq.empty()&&vis[u=pq.top().second])pq.pop();
if(pq.empty()){
myw=506;
}
else{
myw=dis[u]-last_w;
}
send_w(myw);
state=2;
nc=9;
}
else if(state==2){
otherw=rv;
rv=0;
if(min(myw,otherw)>505){
state=-1;
nc=0;
return;
}
last_w+=min(myw,otherw);
if(
(otherw<myw)||(otherw==myw&&id==1)
){
state=3;
nc=11;
}
else{
send_node(u);
state=4;
nc=0;
}
}
else if(state==3){
u=rv;
rv=0;
dis[u]=last_w;
state=4;
nc=0;
}
else if(state==4){
vis[u]=true;
upd(u);
state=1;
nc=0;
}
}
void chk(){
while(!nc&&state!=-1)_chk();
}
void upd(int u){
for(auto it:e[u]){
if(!vis[it.v]&&dis[u]+it.w<dis[it.v]) {
dis[it.v]=dis[u]+it.w;
pq.push(make_pair(-dis[it.v],it.v));
}
}
}
inline void init(){
last_w=0;
memset(dis,0x3f,sizeof(dis));
dis[0]=0;
u=0;
upd(0);
state=1;
nc=0;
chk();
}
vector<int>answer(){
return vector<int>(dis,dis+n);
}
}a[2];
inline void receive(int x,bool v){
a[x].receive(v);
}
inline void init(int x,int n,int m,vector<int>u,vector<int>v,vector<int>w){
a[x].n=n;
a[x].id=x;
for(int i=0;i<m;++i)a[x].build(u[i],v[i],w[i]);
a[x].init();
}
};
std::vector<int>Answer(){
return my::a[0].answer();
}
void InitA(int N, int A, std::vector<int> U, std::vector<int> V, std::vector<int> C){
my::init(0,N,A,U,V,C);
}
void ReceiveA(bool x){
my::receive(0,x);
}
void InitB(int N, int B, std::vector<int> S, std::vector<int> T, std::vector<int> D){
my::init(1,N,B,S,T,D);
}
void ReceiveB(bool x){
my::receive(1,x);
}
詳細信息
Azer.code:1:9: fatal error: transportations.h: No such file or directory 1 | #include"transportations.h" | ^~~~~~~~~~~~~~~~~~~ compilation terminated. grader_Azer.cpp: In function ‘int main(int, char**)’: grader_Azer.cpp:37:13: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings] 37 | char *t = "/dev/null"; | ^~~~~~~~~~~