QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#420511#67. Two TransportationsAFewSuns0 1ms4168kbC++205.7kb2024-05-24 19:36:522024-05-24 19:36:52

Judging History

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

  • [2024-05-24 19:36:52]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:4168kb
  • [2024-05-24 19:36:52]
  • 提交

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);}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

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

output:

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

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: 4148kb

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

output:

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

input:


output:

0

result:

ok single line: '0'

Test #8:

score: 0
Wrong Answer
time: 1ms
memory: 4008kb

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

output:

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

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: '128264', found: '991952896'

Subtask #3:

score: 0
Wrong Answer

Test #14:

score: 8
Accepted
time: 0ms
memory: 3920kb

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

output:

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

input:


output:

0
3328
4161
4895
4209
3745
3720
4315
3313
4008
2104
3319
3666
3501
3499
3359
4244
3853
1906
392
2028
3840
3209
2376
3001
5530
2494
3340
5583
3653
3624
3798
4121
2243
4252
2165
4289
2935
6032
5124
5255
1362
3336
5054
4411
6329
4444
2299
2294
3848
5170
3200
1544
3953
3577
5969
6227
3533
4569
2619
2738...

result:

ok 2000 lines

Test #15:

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

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

output:

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

input:


output:

0

result:

ok single line: '0'

Test #16:

score: 0
Wrong Answer
time: 1ms
memory: 4020kb

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

output:

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

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: '420095', found: '991952896'

Subtask #4:

score: 0
Wrong Answer

Test #24:

score: 0
Wrong Answer
time: 1ms
memory: 3908kb

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

output:

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

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: '1881', found: '991952896'

Subtask #5:

score: 0
Wrong Answer

Test #38:

score: 0
Wrong Answer
time: 1ms
memory: 3872kb

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

output:

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

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: '3467', found: '991952896'

Subtask #6:

score: 0
Wrong Answer

Test #51:

score: 0
Wrong Answer
time: 1ms
memory: 3936kb

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

output:

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

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: '4745', found: '991952896'

Subtask #7:

score: 0
Wrong Answer

Test #64:

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

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

output:

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

input:


output:


result:

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