QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#720137#67. Two TransportationsK8He0 151ms22148kbC++203.6kb2024-11-07 10:49:112024-11-07 10:49:11

Judging History

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

  • [2024-11-07 10:49:11]
  • 评测
  • 测评结果:0
  • 用时:151ms
  • 内存:22148kb
  • [2024-11-07 10:49:11]
  • 提交

Azer

#include <bits/stdc++.h>
#define _for(i, a, b) for (int i = a; i <= b; ++i)
#define for_(i, a, b) for (int i = a; i >= b; --i)
#define far(i, vec) for (auto i : vec)
#define bdmd int mid = (l + r) >> 1
typedef long double ldb;
typedef long long ll;
typedef double db;
typedef std::pair <int, int> pii;
typedef std::pair <ll, ll> pll;
#include "Azer.h"
#include <vector>

namespace A {

	int N;
	std::vector <int> dis;
	std::vector <int> vis;
	std::vector <std::vector <pii> > tu;

	int type, len, au, bu, ad, bd, last;

	void Upd (int u) {
		dis[u] = last;
		vis[u] = true;
		far (p, tu[u]) {
			int v = p.first, w = p.second;
			dis[v] = std::min (dis[v], dis[u] + w);
		}
		au = -1;
		_for (u, 0, N - 1) {
			if (!vis[u]) {
				if (au == -1 || dis[au] > dis[u])
					au = u;
			}
		}
		if (au == -1) return;
		ad = dis[au] - last;
		for_ (i, 8, 0) SendA ((ad >> i) & 1);
		bu = 0, bd = 0, type = 0, len = 9;
		return;
	}

	void InitA (int N, int A, std::vector <int> U, std::vector <int> V, std::vector <int> C) {
		A::N = N;
		dis.resize (N, 1e6);
		vis.resize (N, 0);
		tu.resize (N);
		_for (i, 0, A - 1) {
			tu[U[i]].emplace_back (V[i], C[i]);
			tu[V[i]].emplace_back (U[i], C[i]);
		}
		au = bu = ad = bd = 0;
		Upd (0);
		return;
	}

	void ReceiveA (bool x) {
		if (type) bu = bu << 1 | x;
		else bd = bd << 1 | x;
		if (!(--len)) {
			if (type) last += bd, Upd (bu);
			else {
				if (ad <= bd) {
					for_ (i, 10, 0) SendA ((au >> i) & 1);
					last += ad, Upd (au);
				}
				else type = 1, len = 11;
			}
		}
		return;
	}

}  // namespace A

void InitA (int N, int A, std::vector <int> U, std::vector <int> V, std::vector <int> C) { A::InitA (N, A, U, V, C); }
void ReceiveA (bool x) { A::ReceiveA (x); }
std::vector <int> Answer () { return A::dis; }

Baijan

#include <bits/stdc++.h>
#define _for(i, a, b) for (int i = a; i <= b; ++i)
#define for_(i, a, b) for (int i = a; i >= b; --i)
#define far(i, vec) for (auto i : vec)
#define bdmd int mid = (l + r) >> 1
typedef long double ldb;
typedef long long ll;
typedef double db;
typedef std::pair <int, int> pii;
typedef std::pair <ll, ll> pll;
#include "Baijan.h"
#include <vector>

namespace B {

	int N;
	std::vector <int> dis;
	std::vector <int> vis;
	std::vector <std::vector <pii> > tu;

	int type, len, au, bu, ad, bd, last;

	void Upd (int u) {
		dis[u] = last;
		vis[u] = true;
		far (p, tu[u]) {
			int v = p.first, w = p.second;
			dis[v] = std::min (dis[v], dis[u] + w);
		}
		bu = -1;
		_for (u, 0, N - 1) {
			if (!vis[u]) {
				if (bu == -1 || dis[bu] > dis[u])
					bu = u;
			}
		}
		if (bu == -1) return;
		bd = dis[bu] - last;
		for_ (i, 8, 0) SendB ((bd >> i) & 1);
		au = 0, ad = 0, type = 0, len = 9;
		return;
	}

	void InitB (int N, int B, std::vector <int> S, std::vector <int> T, std::vector <int> C) {
		B::N = N;
		dis.resize (N, 1e6);
		vis.resize (N, 0);
		tu.resize (N);
		_for (i, 0, B - 1) {
			tu[S[i]].emplace_back (T[i], C[i]);
			tu[T[i]].emplace_back (S[i], C[i]);
		}
		au = bu = ad = bd = 0;
		Upd (0);
		return;
	}

	void ReceiveB (bool x) {
		if (type) au = au << 1 | x;
		else ad = ad << 1 | x;
		if (!(--len)) {
			if (type) last += ad, Upd (au);
			else {
				if (bd < ad) {
					for_ (i, 10, 0) SendB ((bu >> i) & 1);
					last += bd, Upd (bu);
				}
				else type = 1, len = 11;
			}
		}
		return;
	}

}  // namespace B

void InitB (int N, int B, std::vector <int> S, std::vector <int> T, std::vector <int> C) { B::InitB (N, B, S, T, C); }
void ReceiveB (bool x) { B::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: 4004kb

input:

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

output:

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

input:


output:

0
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
10...

result:

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

Subtask #2:

score: 0
Wrong Answer

Test #7:

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

input:

-1

output:

-1
-1

input:


output:

0

result:

ok single line: '0'

Test #8:

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

input:

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

output:

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

input:


output:

0
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
10...

result:

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

Subtask #3:

score: 0
Wrong Answer

Test #14:

score: 8
Accepted
time: 11ms
memory: 3924kb

input:

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

output:

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

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

input:

-1

output:

-1
-1

input:


output:

0

result:

ok single line: '0'

Test #16:

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

input:

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

output:

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

input:


output:

0
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
10...

result:

wrong answer 2nd lines differ - expected: '420095', found: '1000000'

Subtask #4:

score: 0
Wrong Answer

Test #24:

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

input:

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

output:

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

input:


output:

0
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
10...

result:

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

Subtask #5:

score: 0
Wrong Answer

Test #38:

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

input:

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

output:

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

input:


output:

0
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
10...

result:

wrong answer 2nd lines differ - expected: '3467', found: '1000000'

Subtask #6:

score: 0
Wrong Answer

Test #51:

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

input:

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

output:

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

input:


output:

0
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
10...

result:

wrong answer 2nd lines differ - expected: '4745', found: '1000000'

Subtask #7:

score: 0
Wrong Answer

Test #64:

score: 16
Accepted
time: 22ms
memory: 4068kb

input:

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

output:

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

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: 143ms
memory: 22148kb

input:

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

output:

-1
0 0 0 0 0 0 0 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
1 1 1 0 1 0 1 1 1 0 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: 151ms
memory: 20272kb

input:

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

output:

-1
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 1 1 0 0 0 1 1 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
Wrong Answer
time: 1ms
memory: 4044kb

input:

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

output:

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

input:


output:

0
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
1000000
10...

result:

wrong answer 2nd lines differ - expected: '79964', found: '1000000'