Submission #472402

# Submission time Handle Problem Language Result Execution time Memory
472402 2021-09-13T13:02:02 Z flappybird Two Transportations (JOI19_transportations) C++14
0 / 100
216 ms 684 KB
#include "Azer.h"
#include <bits/stdc++.h>
using namespace std;
typedef int ll;

namespace {
	ll N, A;
	vector<ll> dis, chk;
	vector<ll> U, V, C;
	ll cnt = 0;
	ll c, v;
	ll pmv;
	ll pmn;
	ll pv;
	ll res;
	ll mode = 0;
	ll mv;
	ll val;
	priority_queue<pair<ll, ll>> pq;
	vector<vector<pair<ll, ll>>> adj;
	void send(ll, ll);
	void func();

	void send(ll x, ll a) {
		ll i;
		for (i = a - 1; i >= 0; i--) SendA(x & (1 << i));
	}

	void func() {
		ll i;
		ll asdfsdf = 1;
		for (i = 1; i < N; i++) if (!chk[i]) asdfsdf = 0;
		if (asdfsdf) return;
		ll mn = 511;
		mv = -1;
		pair<ll, ll> t;
		while (pq.size()) {
			t = pq.top();
			pq.pop();
			if (chk[t.second]) continue;
			mv = t.second;
			break;
		}
		val = min(511, mn - pv);
		send(val, 9);
	}
}  // namespace


void ReceiveA(bool x) {
	res *= 2;
	if (x) res++;
	cnt++;
	if (mode == 0) {
		if (cnt == 9) {
			cnt = 0;
			if (val <= res) {
				send(mv, 11);
				dis[mv] = val + pv;
				pv = dis[mv];
				chk[mv] = 1;
				res = 0;
				for (auto x : adj[mv]) {
					if (chk[x.first]) continue;
					pq.emplace(-(x.second + dis[mv]), x.first);
				}
				func();
			}
			else mode = 1, val = res, res = 0;
		}
	}
	else {
		if (cnt == 11) {
			dis[res] = val + pv;
			pv = dis[res];
			chk[res] = 1;
			cnt = 0;
			mode = 0;
			res = 0;
			for (auto x : adj[res]) {
				if (chk[x.first]) continue;
				pq.emplace(-(x.second + dis[res]), x.first);
			}
			func();
		}
	}
}

std::vector<int> Answer() {
	return dis;
}


void InitA(int _N, int _A, vector<ll> _U, vector<ll> _V, vector<ll> _C) {
	tie(N, A, U, V, C) = make_tuple(_N, _A, _U, _V, _C);
	dis.resize(N);
	chk.resize(N);
	ll i;
	for (i = 1; i < N; i++) dis[i] = 1010101010;
	chk[0] = 1;
	mode = 0;
	res = 0;
	adj.resize(N);
	for (i = 0; i < A; i++) adj[U[i]].emplace_back(V[i], C[i]), adj[V[i]].emplace_back(U[i], C[i]);
	for (i = 0; i < adj[0].size(); i++) pq.emplace(-adj[0][i].second, adj[0][i].first);
	func();
}
#include "Baijan.h"
#include <bits/stdc++.h>
using namespace std;
typedef int ll;

namespace {
	ll N, B;
	ll cnt = 0;
	vector<ll> S, T, D;
	ll res = 0;
	ll pv = 0;
	ll mode;
	vector<ll> chk;
	vector<ll> dis;
	ll val;
	ll mv;
	priority_queue<pair<ll, ll>> pq;
	vector<vector<pair<ll, ll>>> adj;

	void send(ll x, ll a) {
		ll i;
		for (i = a - 1; i >= 0; i--) SendB(x & (1 << i));
	}

	void func() {
		ll i;
		ll mn = 511;
		mv = -1;
		pair<ll, ll> t;
		while (pq.size()) {
			t = pq.top();
			pq.pop();
			if (chk[t.second]) continue;
			mv = t.second;
			break;
		}
		val = min(511, -t.first - pv);
	}
}  // namespace

void InitB(int _N, int _B, vector<int> _S, vector<int> _T, vector<int> _D) {
	tie(N, B, S, T, D) = make_tuple(_N, _B, _S, _T, _D);
	ll i;
	dis.resize(N);
	chk.resize(N);
	for (i = 1; i < N; i++) dis[i] = 1010101010;
	chk[0] = 1;
	mode = 0;
	res = 0;
	adj.resize(N);
	for (i = 0; i < B; i++) adj[S[i]].emplace_back(T[i], D[i]), adj[T[i]].emplace_back(S[i], D[i]);
	for (i = 0; i < adj[0].size(); i++) pq.emplace(-adj[0][i].second, adj[0][i].first);
}

void ReceiveB(bool y) {
	res *= 2;
	if (y) res++;
	cnt++;
	if (!mode) {
		if (cnt == 9) {
			func();
			send(val, 9);
			cnt = 0;
			if (val < res) {
				send(mv, 11);
				dis[mv] = pv + val;
				pv = dis[mv];
				chk[mv] = 1;
				res = 0;
				for (auto x : adj[mv]) {
					if (chk[x.first]) continue;
					pq.emplace(-(x.second + dis[mv]), x.first);
				}
			}
			else mode = 1, val = res, res = 0;
		}
	}
	else {
		if (cnt == 11) {
			cnt = 0;
			dis[res] = val + pv;
			pv = dis[res];
			chk[res] = 1;
			mode = 0;
			res = 0;
			for (auto x : adj[res]) {
				if (chk[x.first]) continue;
				pq.emplace(-(x.second + dis[res]), x.first);
			}
		}
	}
}

Compilation message

Azer.cpp: In function 'void InitA(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
Azer.cpp:105:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  105 |  for (i = 0; i < adj[0].size(); i++) pq.emplace(-adj[0][i].second, adj[0][i].first);
      |              ~~^~~~~~~~~~~~~~~
Azer.cpp: At global scope:
Azer.cpp:13:5: warning: '{anonymous}::pmn' defined but not used [-Wunused-variable]
   13 |  ll pmn;
      |     ^~~
Azer.cpp:12:5: warning: '{anonymous}::pmv' defined but not used [-Wunused-variable]
   12 |  ll pmv;
      |     ^~~
Azer.cpp:11:8: warning: '{anonymous}::v' defined but not used [-Wunused-variable]
   11 |  ll c, v;
      |        ^
Azer.cpp:11:5: warning: '{anonymous}::c' defined but not used [-Wunused-variable]
   11 |  ll c, v;
      |     ^

Baijan.cpp: In function 'void {anonymous}::func()':
Baijan.cpp:26:6: warning: unused variable 'i' [-Wunused-variable]
   26 |   ll i;
      |      ^
Baijan.cpp:27:6: warning: unused variable 'mn' [-Wunused-variable]
   27 |   ll mn = 511;
      |      ^~
Baijan.cpp: In function 'void InitB(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
Baijan.cpp:52:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |  for (i = 0; i < adj[0].size(); i++) pq.emplace(-adj[0][i].second, adj[0][i].first);
      |              ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 212 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 404 KB Output is correct
2 Runtime error 188 ms 684 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 209 ms 672 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 216 ms 464 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 216 ms 464 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 216 ms 464 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 212 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -