Submission #118854

# Submission time Handle Problem Language Result Execution time Memory
118854 2019-06-19T23:51:38 Z tmwilliamlin168 Two Transportations (JOI19_transportations) C++14
100 / 100
1850 ms 85224 KB
#include "Azer.h"
#include <bits/stdc++.h>
using namespace std;

namespace {
	int ld, st;
	array<int, 2> u{};
	queue<bool> bs;
	vector<int> d;
	vector<array<int, 2>> adj[2000];
	priority_queue<array<int, 2>, vector<array<int, 2>>, greater<array<int, 2>>> pq;
	bool s[2000];

	void sendInt(int x, int d) {
		for(int i=0; i<d; ++i)
			SendA(x>>i&1);
	}

	int readInt(int d) {
		int r=0;
		for(int i=0; i<d; ++i) {
			r|=bs.front()<<i;
			bs.pop();
		}
		return r;
	}

	void an() {
		if(u[0]>ld+500)
			return;
		d[u[1]]=u[0];
		s[u[1]]=1;
		for(array<int, 2> v : adj[u[1]]) {
			if(u[0]+v[0]<d[v[1]]) {
				d[v[1]]=u[0]+v[0];
				pq.push({d[v[1]], v[1]});
			}
		}
		ld=u[0];
		u={1, 0};
		while(pq.size()&&s[u[1]]) {
			u=pq.top();
			pq.pop();
		}
		if(s[u[1]])
			u[0]=ld+501;
		sendInt(u[0]-ld, 9);
		st=1;
	}
};

void InitA(int n, int a, vector<int> u, vector<int> v, vector<int> c) {
	for(int i=0; i<a; ++i) {
		adj[u[i]].push_back({c[i], v[i]});
		adj[v[i]].push_back({c[i], u[i]});
	}
	d=vector<int>(n, 1e9);
	d[0]=0;
	an();
}

void ReceiveA(bool x) {
	bs.push(x);
	if(st==1) {
		if(bs.size()<9)
			return;
		int od=readInt(9);
		if(ld+od<u[0]) {
			pq.push(u);
			u[0]=ld+od;
			st=2;
		} else {
			sendInt(u[1], 11);
			an();
		}
	} else if(st==2) {
		if(bs.size()<11)
			return;
		u[1]=readInt(11);
		an();
	}
}

vector<int> Answer() {
	return d;
}
#include "Baijan.h"
#include <bits/stdc++.h>
using namespace std;

namespace {
	int ld, st;
	array<int, 2> u;
	queue<bool> bs;
	vector<int> d;
	vector<array<int, 2>> adj[2000];
	priority_queue<array<int, 2>, vector<array<int, 2>>, greater<array<int, 2>>> pq;
	bool s[2000];

	void sendInt(int x, int d) {
		for(int i=0; i<d; ++i)
			SendB(x>>i&1);
	}

	int readInt(int d) {
		int r=0;
		for(int i=0; i<d; ++i) {
			r|=bs.front()<<i;
			bs.pop();
		}
		return r;
	}

	void an() {
		if(u[0]>ld+500)
			return;
		d[u[1]]=u[0];
		s[u[1]]=1;
		for(array<int, 2> v : adj[u[1]]) {
			if(u[0]+v[0]<d[v[1]]) {
				d[v[1]]=u[0]+v[0];
				pq.push({d[v[1]], v[1]});
			}
		}
		ld=u[0];
		u={1, 0};
		while(pq.size()&&s[u[1]]) {
			u=pq.top();
			pq.pop();
		}
		if(s[u[1]])
			u[0]=ld+501;
		sendInt(u[0]-ld, 9);
		st=1;
	}
};

void InitB(int n, int b, vector<int> s, vector<int> t, vector<int> c) {
	for(int i=0; i<b; ++i) {
		adj[s[i]].push_back({c[i], t[i]});
		adj[t[i]].push_back({c[i], s[i]});
	}
	d=vector<int>(n, 1e9);
	an();
}

void ReceiveB(bool x) {
	bs.push(x);
	if(st==1) {
		if(bs.size()<9)
			return;
		int od=readInt(9);
		if(ld+od<=u[0]) {
			pq.push(u);
			u[0]=ld+od;
			st=2;
		} else {
			sendInt(u[1], 11);
			an();
		}
	} else if(st==2) {
		if(bs.size()<11)
			return;
		u[1]=readInt(11);
		an();
	}
}
# Verdict Execution time Memory Grader output
1 Correct 978 ms 1504 KB Output is correct
2 Correct 4 ms 960 KB Output is correct
3 Correct 1138 ms 1656 KB Output is correct
4 Correct 1350 ms 19872 KB Output is correct
5 Correct 62 ms 1856 KB Output is correct
6 Correct 1012 ms 4384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1216 KB Output is correct
2 Correct 900 ms 1456 KB Output is correct
3 Correct 1072 ms 1704 KB Output is correct
4 Correct 1488 ms 55080 KB Output is correct
5 Correct 1444 ms 48176 KB Output is correct
6 Correct 178 ms 1248 KB Output is correct
7 Correct 1532 ms 48208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1265 ms 1424 KB Output is correct
2 Correct 4 ms 1088 KB Output is correct
3 Correct 1096 ms 1504 KB Output is correct
4 Correct 1040 ms 1600 KB Output is correct
5 Correct 1028 ms 1672 KB Output is correct
6 Correct 1066 ms 1640 KB Output is correct
7 Correct 1095 ms 1648 KB Output is correct
8 Correct 1296 ms 1248 KB Output is correct
9 Correct 1008 ms 1496 KB Output is correct
10 Correct 962 ms 1728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 706 ms 1632 KB Output is correct
2 Correct 504 ms 1400 KB Output is correct
3 Correct 728 ms 23768 KB Output is correct
4 Correct 424 ms 1416 KB Output is correct
5 Correct 690 ms 17408 KB Output is correct
6 Correct 406 ms 1368 KB Output is correct
7 Correct 546 ms 1616 KB Output is correct
8 Correct 424 ms 1760 KB Output is correct
9 Correct 748 ms 36008 KB Output is correct
10 Correct 781 ms 35776 KB Output is correct
11 Correct 1164 ms 61024 KB Output is correct
12 Correct 926 ms 53536 KB Output is correct
13 Correct 384 ms 1856 KB Output is correct
14 Correct 6 ms 1168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 706 ms 1632 KB Output is correct
2 Correct 504 ms 1400 KB Output is correct
3 Correct 728 ms 23768 KB Output is correct
4 Correct 424 ms 1416 KB Output is correct
5 Correct 690 ms 17408 KB Output is correct
6 Correct 406 ms 1368 KB Output is correct
7 Correct 546 ms 1616 KB Output is correct
8 Correct 424 ms 1760 KB Output is correct
9 Correct 748 ms 36008 KB Output is correct
10 Correct 781 ms 35776 KB Output is correct
11 Correct 1164 ms 61024 KB Output is correct
12 Correct 926 ms 53536 KB Output is correct
13 Correct 384 ms 1856 KB Output is correct
14 Correct 6 ms 1168 KB Output is correct
15 Correct 454 ms 1600 KB Output is correct
16 Correct 384 ms 1360 KB Output is correct
17 Correct 757 ms 1504 KB Output is correct
18 Correct 848 ms 17632 KB Output is correct
19 Correct 500 ms 1664 KB Output is correct
20 Correct 860 ms 18384 KB Output is correct
21 Correct 660 ms 1504 KB Output is correct
22 Correct 446 ms 1856 KB Output is correct
23 Correct 1054 ms 43992 KB Output is correct
24 Correct 989 ms 43920 KB Output is correct
25 Correct 1476 ms 74904 KB Output is correct
26 Correct 1263 ms 63936 KB Output is correct
27 Correct 638 ms 1504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 706 ms 1632 KB Output is correct
2 Correct 504 ms 1400 KB Output is correct
3 Correct 728 ms 23768 KB Output is correct
4 Correct 424 ms 1416 KB Output is correct
5 Correct 690 ms 17408 KB Output is correct
6 Correct 406 ms 1368 KB Output is correct
7 Correct 546 ms 1616 KB Output is correct
8 Correct 424 ms 1760 KB Output is correct
9 Correct 748 ms 36008 KB Output is correct
10 Correct 781 ms 35776 KB Output is correct
11 Correct 1164 ms 61024 KB Output is correct
12 Correct 926 ms 53536 KB Output is correct
13 Correct 384 ms 1856 KB Output is correct
14 Correct 6 ms 1168 KB Output is correct
15 Correct 454 ms 1600 KB Output is correct
16 Correct 384 ms 1360 KB Output is correct
17 Correct 757 ms 1504 KB Output is correct
18 Correct 848 ms 17632 KB Output is correct
19 Correct 500 ms 1664 KB Output is correct
20 Correct 860 ms 18384 KB Output is correct
21 Correct 660 ms 1504 KB Output is correct
22 Correct 446 ms 1856 KB Output is correct
23 Correct 1054 ms 43992 KB Output is correct
24 Correct 989 ms 43920 KB Output is correct
25 Correct 1476 ms 74904 KB Output is correct
26 Correct 1263 ms 63936 KB Output is correct
27 Correct 638 ms 1504 KB Output is correct
28 Correct 652 ms 1760 KB Output is correct
29 Correct 690 ms 1680 KB Output is correct
30 Correct 1070 ms 42192 KB Output is correct
31 Correct 854 ms 1336 KB Output is correct
32 Correct 979 ms 37680 KB Output is correct
33 Correct 864 ms 1504 KB Output is correct
34 Correct 858 ms 1936 KB Output is correct
35 Correct 718 ms 1768 KB Output is correct
36 Correct 1250 ms 49104 KB Output is correct
37 Correct 1196 ms 49056 KB Output is correct
38 Correct 1462 ms 85224 KB Output is correct
39 Correct 1490 ms 78352 KB Output is correct
40 Correct 611 ms 1856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 978 ms 1504 KB Output is correct
2 Correct 4 ms 960 KB Output is correct
3 Correct 1138 ms 1656 KB Output is correct
4 Correct 1350 ms 19872 KB Output is correct
5 Correct 62 ms 1856 KB Output is correct
6 Correct 1012 ms 4384 KB Output is correct
7 Correct 4 ms 1216 KB Output is correct
8 Correct 900 ms 1456 KB Output is correct
9 Correct 1072 ms 1704 KB Output is correct
10 Correct 1488 ms 55080 KB Output is correct
11 Correct 1444 ms 48176 KB Output is correct
12 Correct 178 ms 1248 KB Output is correct
13 Correct 1532 ms 48208 KB Output is correct
14 Correct 1265 ms 1424 KB Output is correct
15 Correct 4 ms 1088 KB Output is correct
16 Correct 1096 ms 1504 KB Output is correct
17 Correct 1040 ms 1600 KB Output is correct
18 Correct 1028 ms 1672 KB Output is correct
19 Correct 1066 ms 1640 KB Output is correct
20 Correct 1095 ms 1648 KB Output is correct
21 Correct 1296 ms 1248 KB Output is correct
22 Correct 1008 ms 1496 KB Output is correct
23 Correct 962 ms 1728 KB Output is correct
24 Correct 706 ms 1632 KB Output is correct
25 Correct 504 ms 1400 KB Output is correct
26 Correct 728 ms 23768 KB Output is correct
27 Correct 424 ms 1416 KB Output is correct
28 Correct 690 ms 17408 KB Output is correct
29 Correct 406 ms 1368 KB Output is correct
30 Correct 546 ms 1616 KB Output is correct
31 Correct 424 ms 1760 KB Output is correct
32 Correct 748 ms 36008 KB Output is correct
33 Correct 781 ms 35776 KB Output is correct
34 Correct 1164 ms 61024 KB Output is correct
35 Correct 926 ms 53536 KB Output is correct
36 Correct 384 ms 1856 KB Output is correct
37 Correct 6 ms 1168 KB Output is correct
38 Correct 454 ms 1600 KB Output is correct
39 Correct 384 ms 1360 KB Output is correct
40 Correct 757 ms 1504 KB Output is correct
41 Correct 848 ms 17632 KB Output is correct
42 Correct 500 ms 1664 KB Output is correct
43 Correct 860 ms 18384 KB Output is correct
44 Correct 660 ms 1504 KB Output is correct
45 Correct 446 ms 1856 KB Output is correct
46 Correct 1054 ms 43992 KB Output is correct
47 Correct 989 ms 43920 KB Output is correct
48 Correct 1476 ms 74904 KB Output is correct
49 Correct 1263 ms 63936 KB Output is correct
50 Correct 638 ms 1504 KB Output is correct
51 Correct 652 ms 1760 KB Output is correct
52 Correct 690 ms 1680 KB Output is correct
53 Correct 1070 ms 42192 KB Output is correct
54 Correct 854 ms 1336 KB Output is correct
55 Correct 979 ms 37680 KB Output is correct
56 Correct 864 ms 1504 KB Output is correct
57 Correct 858 ms 1936 KB Output is correct
58 Correct 718 ms 1768 KB Output is correct
59 Correct 1250 ms 49104 KB Output is correct
60 Correct 1196 ms 49056 KB Output is correct
61 Correct 1462 ms 85224 KB Output is correct
62 Correct 1490 ms 78352 KB Output is correct
63 Correct 611 ms 1856 KB Output is correct
64 Correct 1082 ms 2160 KB Output is correct
65 Correct 1210 ms 47472 KB Output is correct
66 Correct 1406 ms 41024 KB Output is correct
67 Correct 852 ms 2240 KB Output is correct
68 Correct 1051 ms 1832 KB Output is correct
69 Correct 1746 ms 83016 KB Output is correct
70 Correct 1850 ms 67912 KB Output is correct
71 Correct 988 ms 8920 KB Output is correct
72 Correct 1012 ms 2216 KB Output is correct