QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#420509#67. Two TransportationsAFewSuns0 11ms4324kbC++205.7kb2024-05-24 19:35:362024-05-24 19:35:38

Judging History

你现在查看的是最新测评结果

  • [2024-05-24 19:35:38]
  • 评测
  • 测评结果:0
  • 用时:11ms
  • 内存:4324kb
  • [2024-05-24 19:35:36]
  • 提交

Azer

#include<bits/stdc++.h>
#include "Azer.h"
using namespace std;
namespace my_std{
	#define ll long long
	#define bl bool
	ll my_pow(ll a,ll b,ll mod){
		ll res=1;
		if(!b) return 1;
		while(b){
			if(b&1) res=(res*a)%mod;
			a=(a*a)%mod;
			b>>=1;
		}
		return res;
	}
	ll qpow(ll a,ll b){
		ll res=1;
		if(!b) return 1;
		while(b){
			if(b&1) res*=a;
			a*=a;
			b>>=1;
		}
		return res;
	}
	#define db double
	#define pf printf
	#define pc putchar
	#define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
	#define pfr(i,x,y) for(register ll i=(x);i>=(y);i--)
	#define go(u) for(ll i=head[u];i;i=e[i].nxt)
	#define enter pc('\n')
	#define space pc(' ')
	#define fir first
	#define sec second
	#define MP make_pair
	#define il inline
	#define inf 8e18
	#define random(x) rand()*rand()%(x)
	#define inv(a,mod) my_pow((a),(mod-2),(mod))
	il ll read(){
		ll sum=0,f=1;
		char ch=0;
		while(!isdigit(ch)){
			if(ch=='-') f=-1;
			ch=getchar();
		}
		while(isdigit(ch)){
			sum=sum*10+(ch^48);
			ch=getchar();
		}
		return sum*f;
	}
	il void write(ll x){
		if(x<0){
			x=-x;
			pc('-');
		}
		if(x>9) write(x/10);
		pc(x%10+'0');
	}
	il void writeln(ll x){
		write(x);
		enter;
	}
	il void writesp(ll x){
		write(x);
		space;
	}
}
using namespace my_std;
namespace Azer{
	vector<pair<ll,ll> > e[2020];
	ll n,dis[2020],lstw,minn,now,res,lstres;
	bl typ,ck[2020];
	void InitA(int N,int A,vector<int> U,vector<int> V,vector<int> C){
		fr(i,0,A-1){
			e[U[i]].push_back(MP(V[i],C[i]));
			e[V[i]].push_back(MP(U[i],C[i]));
		}
		n=N;
		fr(i,0,n-1) dis[i]=inf;
		dis[0]=lstw=minn=res=typ=0;
		pfr(i,8,0) SendA(0);
		now=8;
	}
	void ReceiveA(bl x){
		res|=(x<<now);
		now--;
		if(now>=0) return;
		if(!typ){
			if(dis[minn]<=(lstw+res)){
				pfr(i,10,0) SendA((minn>>i)&1);
				ck[minn]=1;
				lstw=dis[minn];
				fr(i,0,(ll)e[minn].size()-1){
					ll v=e[minn][i].fir,w=e[minn][i].sec;
					dis[v]=min(dis[v],dis[minn]+w);
				}
				minn=-1;
				fr(i,1,n) if(!ck[i]&&(minn==-1||dis[minn]>dis[i])) minn=i;
				if(minn==-1){
					Answer();
					return;
				}
				res=typ=0;
				pfr(i,8,0) SendA(((dis[minn]-lstw)>>i)&1);
				now=8;
			}
			else{
				lstres=res;
				res=0;
				typ=1;
				now=10;
				return;
			}
		}
		else{
			minn=res;
			dis[minn]=lstw+lstres;
			ck[minn]=1;
			lstw=dis[minn];
			fr(i,0,(ll)e[minn].size()-1){
				ll v=e[minn][i].fir,w=e[minn][i].sec;
				dis[v]=min(dis[v],dis[minn]+w);
			}
			minn=-1;
			fr(i,1,n) if(!ck[i]&&(minn==-1||dis[minn]>dis[i])) minn=i;
			if(minn==-1){
				Answer();
				return;
			}
			res=typ=0;
			pfr(i,8,0) SendA(((dis[minn]-lstw)>>i)&1);
			now=8;
		}
	}
	vector<int> Answer(){
		vector<int> ans;
		fr(i,0,n-1) ans.push_back(dis[i]);
		return ans;
	}
}
void InitA(int N,int A,vector<int> U,vector<int> V,vector<int> C){Azer::InitA(N,A,U,V,C);}
void ReceiveA(bl x){Azer::ReceiveA(x);}
vector<int> Answer(){return Azer::Answer();}

Baijan

#include<bits/stdc++.h>
#include "Baijan.h"
using namespace std;
namespace my_std{
	#define ll long long
	#define bl bool
	ll my_pow(ll a,ll b,ll mod){
		ll res=1;
		if(!b) return 1;
		while(b){
			if(b&1) res=(res*a)%mod;
			a=(a*a)%mod;
			b>>=1;
		}
		return res;
	}
	ll qpow(ll a,ll b){
		ll res=1;
		if(!b) return 1;
		while(b){
			if(b&1) res*=a;
			a*=a;
			b>>=1;
		}
		return res;
	}
	#define db double
	#define pf printf
	#define pc putchar
	#define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
	#define pfr(i,x,y) for(register ll i=(x);i>=(y);i--)
	#define go(u) for(ll i=head[u];i;i=e[i].nxt)
	#define enter pc('\n')
	#define space pc(' ')
	#define fir first
	#define sec second
	#define MP make_pair
	#define il inline
	#define inf 8e18
	#define random(x) rand()*rand()%(x)
	#define inv(a,mod) my_pow((a),(mod-2),(mod))
	il ll read(){
		ll sum=0,f=1;
		char ch=0;
		while(!isdigit(ch)){
			if(ch=='-') f=-1;
			ch=getchar();
		}
		while(isdigit(ch)){
			sum=sum*10+(ch^48);
			ch=getchar();
		}
		return sum*f;
	}
	il void write(ll x){
		if(x<0){
			x=-x;
			pc('-');
		}
		if(x>9) write(x/10);
		pc(x%10+'0');
	}
	il void writeln(ll x){
		write(x);
		enter;
	}
	il void writesp(ll x){
		write(x);
		space;
	}
}
using namespace my_std;
namespace Baijan{
	vector<pair<ll,ll> > e[2020];
	ll n,dis[2020],lstw,minn,now,res,lstres;
	bl typ,ck[2020];
	void InitB(int N,int B,vector<int> S,vector<int> T,vector<int> D){
		fr(i,0,B-1){
			e[S[i]].push_back(MP(T[i],D[i]));
			e[T[i]].push_back(MP(S[i],D[i]));
		}
		n=N;
		fr(i,0,n-1) dis[i]=inf;
		dis[0]=lstw=minn=res=typ=0;
		pfr(i,8,0) SendB(0);
		now=8;
	}
	void ReceiveB(bl x){
		res|=(x<<now);
		now--;
		if(now>=0) return;
		if(!typ){
			if(dis[minn]<=(lstw+res)){
				pfr(i,10,0) SendB((minn>>i)&1);
				ck[minn]=1;
				lstw=dis[minn];
				fr(i,0,(ll)e[minn].size()-1){
					ll v=e[minn][i].fir,w=e[minn][i].sec;
					dis[v]=min(dis[v],dis[minn]+w);
				}
				minn=-1;
				fr(i,1,n) if(!ck[i]&&(minn==-1||dis[minn]>dis[i])) minn=i;
				if(minn==-1) return;
				res=typ=0;
				pfr(i,8,0) SendB(((dis[minn]-lstw)>>i)&1);
				now=8;
			}
			else{
				lstres=res;
				res=0;
				typ=1;
				now=10;
				return;
			}
		}
		else{
			minn=res;
			dis[minn]=lstw+lstres;
			ck[minn]=1;
			lstw=dis[minn];
			fr(i,0,(ll)e[minn].size()-1){
				ll v=e[minn][i].fir,w=e[minn][i].sec;
				dis[v]=min(dis[v],dis[minn]+w);
			}
			minn=-1;
			fr(i,1,n) if(!ck[i]&&(minn==-1||dis[minn]>dis[i])) minn=i;
			if(minn==-1) return;
			res=typ=0;
			pfr(i,8,0) SendB(((dis[minn]-lstw)>>i)&1);
			now=8;
		}
	}
}
void InitB(int N,int B,vector<int> S,vector<int> T,vector<int> D){Baijan::InitB(N,B,S,T,D);}
void ReceiveB(bl x){Baijan::ReceiveB(x);}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 4324kb

input:

0 0 0 0 0 0 0 0 0 -1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 -1
0 0 0 0 0 0 0 0 0 1 1 1 0 1 0 0 1 1 -1
1 0 0 0 1 1 1 1 1 -1
0 1 0 0 1 0 0 0 0 -1
0 0 1 1 1 0 1 1 1 -1
0 0 0 0 1 1 0 0 0 -1
-1

output:

-1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1
1 1 1 1 1 0 1 0 0 0 0 0 1 0 1 1 0 1 0 0 0 1 0 1 1 0 1 0 0 -1
0 1 0 1 1 0 1 0 0 0 0 1 1 0 0 1 0 1 0 0 0 1 0 0 0 1 1 1 1 -1
1 0 1 0 1 1 0 1 1 0 1 0 0 0 0 1 1 0 0 1 -1
0 1 0 0 0 1 1 0 0 0 1 0 0 1 0 1 1 1 1 1 -1
1 0 0 1 0 1 1 1 0 1 0 0 0 0 ...

input:


output:

0
991952896
991952896
991952896
991952896
991952896
991952896
991952896
991952896
991952896
991952896
991952896
991952896
991952896
991952896
991952896
991952896
991952896
991952896
991952896
991952896
991952896
991952896
991952896
991952896
991952896
991952896
991952896
991952896
991952896
99195289...

result:

wrong answer 2nd lines differ - expected: '2417', found: '991952896'

Subtask #2:

score: 0
Wrong Answer

Test #7:

score: 8
Accepted
time: 1ms
memory: 3844kb

input:

0 0 0 0 0 0 0 0 0 -1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

-1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

input:


output:

0

result:

ok single line: '0'

Test #8:

score: 0
Wrong Answer
time: 3ms
memory: 3968kb

input:

0 0 0 0 0 0 0 0 0 -1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 -1
1 1 0 1 0 0 1 1 0 1 0 1 1 1 0 0 0 1 -1
0 1 1 1 0 1 1 1 0 -1
0 1 0 0 1 1 1 0 0 -1
0 0 1 1 1 0 0 1 0 0 1 1 1 1 0 1 0 1 0 1 0 0 1 0 0 1 0 0 0 -1
0 0 1 1 1 1 0 0 0 0 0 0 0 1 1 0 0 0 1 1 -1
0 1 0 1 0 0...

output:

-1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1
1 1 1 1 1 0 1 0 0 0 0 0 1 1 0 1 0 1 0 1 0 1 0 0 0 0 0 1 1 -1
0 1 0 0 0 0 0 1 1 1 0 0 0 0 1 1 1 0 0 1 0 0 1 0 1 0 0 1 0 -1
0 0 1 0 0 1 1 1 0 0 0 0 0 0 1 0 1 0 1 0 -1
0 1 0 0 0 1 0 1 0 1 1 1 0 0 0 0 0 0 0 1 -1
0 1 1 0 0 0 1 0 0 -1
0 0 1 1...

input:


output:

0
991952896
991952896
991952896
991952896
991952896
991952896
991952896
991952896
991952896
991952896
991952896
991952896
991952896
991952896
2481
991952896
991952896
5714
991952896
9071
991952896
991952896
991952896
991952896
991952896
991952896
991952896
991952896
5306
991952896
991952896
99195289...

result:

wrong answer 2nd lines differ - expected: '128264', found: '991952896'

Subtask #3:

score: 0
Interactor Runtime Error

Test #14:

score: 0
Interactor Runtime Error

input:

0 0 0 0 0 0 0 0 0 -1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 1 0 0 0 0 1 0 0 1 1 1 0 0 1 -1
0 1 1 1 0 0 0 1 1 0 0 1 1 1 1 0 1 0 -1
0 1 0 1 0 1 0 1 0 0 1 0 0 1 0 1 0 1 1 0 -1
0 0 0 0 1 1 1 0 0 1 1 0 0 0 0 0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1 1 0 1 1 1 0 0 0 1 0 0 0 0 1 -1
0 1 1 0...

input:


output:

0
991952896
991952896
1204
991952896
2508
48734
991952896
991952896
991952896
1730
4681
991952896
1297
991952896
991952896
991952896
4523
1626
2195
3250
19801
991952896
991952896
28663
33773
991952896
28019
991952896
24124
991952896
991952896
43003
991952896
991952896
991952896
991952896
17995
99195...

result:

wrong answer 2nd lines differ - expected: '1881', found: '991952896'

Subtask #5:

score: 0
Runtime Error

Test #38:

score: 0
Runtime Error

input:

0 0 0 0 0 0 0 0 0 -1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 1 0 0 0 0 1 0 1 1 1 1 0 -1
0 0 1 0 1 1 1 1 0 0 0 1 0 1 1 1 1 0 -1
0 1 1 1 0 1 1 1 1 0 0 0 1 1 1 0 1 0 0 0 -1
1 0 0 0 0 0 1 0 0 0 0 0 1 0 1 1 1 0 1 0 -1
0 0 0 1 1 0 1 0 1 -1
1 0 0 1 0 1 1 0 1 -1
0 1 1 1 1 1 0 0 1 -1
0 0 0 0 ...

output:

-1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1
1 0 0 0 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1
1 1 1 1 0 1 0 0 1 -1
1 0 1 1 0 1 1 0 1 -1
0 1 0 0 0 0 1 0 1 0 1 1 0 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 -1
0 1 1 0 1 1 1 0 0 0 1 0 0 0 1 1 0 1 0 0 -1
0 1 1 1 1 1 0 0 0 0 1 0 1 1 1...

input:


output:


result:

wrong answer 1st lines differ - expected: '0', found: ''

Subtask #6:

score: 0
Interactor Runtime Error

Test #51:

score: 0
Interactor Runtime Error

input:

0 0 0 0 0 0 0 0 0 -1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 1 1 1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1 1 -1
0 1 1 1 1 1 1 1 1 -1
0 0 1 1 0 0 0 1 0 -1
0 0 0 0 1 1 0 1 0 1 1 0 1 0 1 0 1 1 0 0 0 0 1 1 1 1 0 0 0 -1
0 0 1 1 1 0 1 0 0 -1
0 0 0 1 1 0 0 1 1 -1
0 0 0 1 0 1 1 1 0 -1
0 0 1 1 1...

input:


output:


result:

wrong answer 1st lines differ - expected: '0', found: ''