QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#422252#67. Two Transportationslichenghan0 70ms19312kbC++204.9kb2024-05-27 08:35:442024-05-27 08:35:45

Judging History

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

  • [2024-05-27 08:35:45]
  • 评测
  • 测评结果:0
  • 用时:70ms
  • 内存:19312kb
  • [2024-05-27 08:35:44]
  • 提交

Azer

#include "Azer.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;

namespace nsa{
#ifndef LCH
#define printf(...) 1
#endif
	const int WB=9;
	const int NB=11;
	const int N=2002;
	int __rbits,__cur;
	
	int n;
	vector<pair<int,int>> g[N];
	int dis[N],vis[N],ac;
	int lstdi;
	priority_queue<pair<int,int>,vector<pair<int,int>>,
		greater<pair<int,int>>>q;
	int stat=0;
	// stat=0: waiting for val
	// stat=1: waiting for id
	
	void AwaitInt(int bits){ __cur=0,__rbits=bits; }
	void SendInt(int x,int bits){
		printf("Alice send %d (%c)\n",x,"WN"[bits==NB]);
		vector<int> bs;
		for(int i=0;i<bits;i++) bs.push_back(x&1),x>>=1;
		reverse(bs.begin(),bs.end());
		for(int i:bs) SendA(i);
	}
	void ext(int u){
		for(auto [v,w]:g[u]){
			if(dis[v]>dis[u]+w){
				dis[v]=dis[u]+w;
				q.push({dis[v],v});
			}
		}
	}
	void ReceiveInt(int x){
		printf("Alice receive %d\n",x);
		if(stat==0){
			if(x==505) x=1e9;
			else x+=lstdi;
			printf("%d is a value, check\n",x);
			int u=q.top().second;
			printf("cur dist is %d (%d), ",u,dis[u]);
			if(x<dis[u]){
				printf("await\n");
				lstdi=x;
				AwaitInt(NB);
				stat=1;
				return;
			}
			lstdi=dis[u];
			if(x>dis[u]){
				printf("better, send, ");
				SendInt(u,NB);
			}
			vis[u]=true;
			q.pop();
			printf("updt!\n");
			ext(u);
		}else{
			printf("%d is an id, updt dist\n",x);
			dis[x]=lstdi;
			vis[x]=true;
			ext(x);
			stat=0;
		}
		++ac;
		while(!q.empty()){
			int u=q.top().second;
			if(vis[u]){
				q.pop();
				continue;
			}
			printf("new top is %d (%d)\n",u,dis[u]);
			SendInt(dis[u]-lstdi,WB);
			AwaitInt(WB);
			return;
		}
		if(ac<n){
			SendInt(505,WB);
			AwaitInt(WB);
		}
	}
#ifndef LCH
#undef printf
#endif
}

void InitA(int N, int A, std::vector<int> U, std::vector<int> V,
		std::vector<int> C) {
	using namespace nsa;
	n=N;
	memset(dis,0x3f,n*sizeof(int));
	memset(vis,0,n*sizeof(int));
	ac=0;
	dis[0]=0;
	lstdi=0;
	stat=0;
	for(int i=0;i<n;i++) g[i].clear();
	for(int i=0;i<A;i++) g[U[i]].push_back({V[i],C[i]});
	for(int i=0;i<A;i++) g[V[i]].push_back({U[i],C[i]});
	q.push({0,0});
	SendInt(0,WB);
	AwaitInt(WB);
}

void ReceiveA(bool x) {
	using namespace nsa;
	if(!__rbits){
		fprintf(stderr,"Alice wants nothing but bob sends");
		exit(0);
	}
	__rbits--;
	__cur=(__cur<<1)+x;
	if(__rbits==0) ReceiveInt(__cur);
}

std::vector<int> Answer() {
	using namespace nsa;
	std::vector<int> ans(n);
	for(int k=0;k<n;++k) ans[k]=dis[k];
	return ans;
}

Baijan

#include "Baijan.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;

namespace nsb{
#ifndef LCH
#define printf(...) 1
#endif
	const int WB=9;
	const int NB=11;
	const int N=2002;
	int __rbits,__cur;
	
	int n;
	vector<pair<int,int>> g[N];
	int dis[N],vis[N];
	int lstdi,ac;
	// stat: 0=waiting for val, 1=waiting for id, 2=end
	priority_queue<pair<int,int>,vector<pair<int,int>>,
		greater<pair<int,int>>>q;
		int stat=0;
	
	void AwaitInt(int bits){ __cur=0,__rbits=bits; }
	void SendInt(int x,int bits){
		printf("Bob send %d (%c)\n",x,"WN"[bits==NB]);
		vector<int> bs;
		for(int i=0;i<bits;i++) bs.push_back(x&1),x>>=1;
		reverse(bs.begin(),bs.end());
		for(int i:bs) SendB(i);
	}
	void ext(int u){
		for(auto [v,w]:g[u]){
			if(dis[v]>dis[u]+w){
				dis[v]=dis[u]+w;
				q.push({dis[v],v});
			}
		}
	}
	void ReceiveInt(int x){
		printf("Alice receive %d\n",x);
		if(stat==0){
			if(x==505) x=1e9;
			else x+=lstdi;
			printf("%d is a value, check\n",x);
			int u=q.top().second;
			printf("cur dist is %d (%d), ",u,dis[u]);
			if(x<dis[u]){
				printf("await\n");
				lstdi=x;
				AwaitInt(NB);
				stat=1;
				return;
			}
			lstdi=dis[u];
			if(x>dis[u]){
				printf("better, send, ");
				SendInt(u,NB);
			}
			vis[u]=true;
			q.pop();
			printf("updt!\n");
			ext(u);
		}else{
			printf("%d is an id, updt dist\n",x);
			dis[x]=lstdi;
			vis[x]=true;
			ext(x);
			stat=0;
		}
		++ac;
		while(!q.empty()){
			int u=q.top().second;
			if(vis[u]){
				q.pop();
				continue;
			}
			printf("new top is %d (%d)\n",u,dis[u]);
			SendInt(dis[u]-lstdi,WB);
			AwaitInt(WB);
			return;
		}
		if(ac<n){
			SendInt(505,WB);
			AwaitInt(WB);
		}
	}
#ifndef LCH
#undef printf
#endif
}

void InitB(int N, int B, std::vector<int> U, std::vector<int> V,
        std::vector<int> C) {
	using namespace nsb;
	n=N;
	memset(dis,0x3f,n*sizeof(int));
	memset(vis,0,n*sizeof(int));
	ac=0;
	dis[0]=0;
	lstdi=0;
	stat=0;
	for(int i=0;i<n;i++) g[i].clear();
	for(int i=0;i<B;i++) g[U[i]].push_back({V[i],C[i]});
	for(int i=0;i<B;i++) g[V[i]].push_back({U[i],C[i]});
	q.push({0,0});
	SendInt(0,WB);
	AwaitInt(WB);
}

void ReceiveB(bool y) {
	using namespace nsb;
	if(!__rbits){
		fprintf(stderr,"Bob wants nothing but alice sends");
		exit(0);
	}
	__rbits--;
	__cur=(__cur<<1)+y;
	if(__rbits==0) ReceiveInt(__cur);
}

詳細信息

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

score: 0
Time Limit Exceeded

input:

0 0 0 0 0 0 0 0 0 -1

output:

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

input:


output:


result:

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

Subtask #2:

score: 0
Time Limit Exceeded

Test #7:

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

input:

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

output:

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

input:


output:

0

result:

ok single line: '0'

Test #8:

score: 0
Time Limit Exceeded

input:

0 0 0 0 0 0 0 0 0 -1

output:

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

input:


output:


result:

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

Subtask #3:

score: 0
Time Limit Exceeded

Test #14:

score: 0
Time Limit Exceeded

input:

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

output:

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

input:


output:


result:

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

Subtask #4:

score: 0
Time Limit Exceeded

Test #24:

score: 0
Time Limit Exceeded

input:

0 0 0 0 0 0 0 0 0 -1

output:

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

input:


output:


result:

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

Subtask #5:

score: 0
Time Limit Exceeded

Test #38:

score: 0
Time Limit Exceeded

input:

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

output:

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

input:


output:


result:

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

Subtask #6:

score: 0
Time Limit Exceeded

Test #51:

score: 0
Time Limit Exceeded

input:

0 0 0 0 0 0 0 0 0 -1

output:

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

input:


output:


result:

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

Subtask #7:

score: 0
Time Limit Exceeded

Test #64:

score: 16
Accepted
time: 0ms
memory: 4088kb

input:

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

output:

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

input:


output:

0
25855
513884
451446
379664
463677
147972
259014
115396
537065
61376
510191
95200
328777
282337
199131
72153
405843
215292
529082
413220
99569
275396
215884
52889
281825
182731
64473
510973
545141
417123
190844
319517
483688
15462
490221
521781
384795
539004
457181
146029
122086
1730
31958
265013
7...

result:

ok 2000 lines

Test #65:

score: 16
Accepted
time: 70ms
memory: 19312kb

input:

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

output:

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

input:


output:

0
6187
1398
17
6163
4742
4598
2337
2237
6475
6001
5268
2245
6132
4925
1482
4253
1962
6642
2449
2704
3396
5449
2492
706
835
1879
3203
6855
4265
546
1231
2390
2300
4651
1353
1673
6724
6753
360
4275
6749
3400
1385
2945
6010
5339
226
2511
4558
1033
4708
4330
1882
1185
3535
5071
3843
1252
110
6571
6727
3...

result:

ok 2000 lines

Test #66:

score: 16
Accepted
time: 67ms
memory: 17640kb

input:

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

output:

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

input:


output:

0
5455
4313
3996
4463
4115
2413
1141
7939
4669
5854
7806
7612
3394
7713
441
4956
1630
751
2070
4241
6754
3518
3736
3158
549
4590
6798
842
1597
7637
3679
6104
7953
5654
3951
1877
2075
5983
6633
5724
2967
2362
527
7670
3759
3471
4089
508
1187
5437
3533
3003
7429
7499
5966
7484
949
1545
1862
542
3370
1...

result:

ok 2000 lines

Test #67:

score: 0
Time Limit Exceeded

input:

0 0 0 0 0 0 0 0 0 -1

output:

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

input:


output:


result:

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