Submission #123338

# Submission time Handle Problem Language Result Execution time Memory
123338 2019-07-01T07:35:14 Z 임유진(#3021) Two Transportations (JOI19_transportations) C++14
0 / 100
560 ms 1432 KB
#include "Azer.h"
#include <vector>
#include <queue>

#define MAXN 2005

typedef std::pair<int, int> pii;

namespace {

int N;
int count;
int node, dis;
int dp[MAXN], dpn;
std::vector<pii> ed[MAXN];
std::priority_queue<pii, std::vector<pii>, std::greater<pii> > pq;
int lastdis;

void send() {
	if(pq.empty()) {
		for(int i = 0; i < 20; i++) SendA(false);
		//printf("A: node = 0, dis = 0\n");
	}
	else{
		for(int i = 0; i < 11; i++) SendA(pq.top().second & (1<<i) ? true : false);
		for(int i = 0; i < 9; i++) SendA((pq.top().first - lastdis) & (1<<i) ? true : false);
		//printf("A: node = %d, dis = %d\n", pq.top().second, (pq.top().first - lastdis));
	}
}

}

void InitA(int N, int A, std::vector<int> U, std::vector<int> V, std::vector<int> C) {
	//printf("*\n");
	::N = N;
	for(int i = 0; i < U.size(); i++) {
		ed[U[i]].push_back(std::make_pair(C[i], V[i]));
		ed[V[i]].push_back(std::make_pair(C[i], U[i]));
	}
	for(int i = 0; i < N; i++) dp[i] = -1;
	dp[0] = 0;
	for(auto a : ed[0]) pq.push(a);
	send();
}

void ReceiveA(bool x) {
	if(x) {
		if(count < 11) node += 1 << count;
		else dis += 1 << (count - 11);
	}
	count++;
	if(count == 20) {
		count = 0;
		dp[node] = lastdis + dis;
		lastdis = dp[node];
		//printf("A: dp[%d] = %d\n", node, dp[node]);
		for(auto a : ed[node]) if(dp[a.second] == -1) pq.push(std::make_pair(dp[node] + a.first, a.second));
		while(!pq.empty() && dp[pq.top().second] != -1) pq.pop();
		//if(pq.empty()) printf("A: pq empty\n");
		//else printf("A: pq.top() = (%d, %d)\n", pq.top().first, pq.top().second);
		if(++dpn < N) send();
		node = dis = 0;
	}
}

std::vector<int> Answer() {
	std::vector<int> ans(N);
	for(int i = 0; i < N; i++) ans[i] = dp[i];
	return ans;
}
#include "Baijan.h"
#include <vector>
#include <queue>

#define MAXN 2005

typedef std::pair<int, int> pii;

namespace{

int count;
int node, dis;
int dp[MAXN];
std::vector<pii> ed[MAXN];
std::priority_queue<pii, std::vector<pii>, std::greater<pii> > pq;
int lastdis;

void send(int a, int b) {
	for(int i = 0; i < 11; i++) SendB(a & (1<<i) ? true : false);
	for(int i = 0; i < 9; i++) SendB(b & (1<<i) ? true : false);
	//printf("B: node = %d, dis = %d\n", a, b);
}

}

void InitB(int N, int B, std::vector<int> S, std::vector<int> T, std::vector<int> D) {
	for(int i = 0; i < S.size(); i++) {
		ed[S[i]].push_back(std::make_pair(D[i], T[i]));
		ed[T[i]].push_back(std::make_pair(D[i], S[i]));
	}
	for(int i = 0; i < N; i++) dp[i] = -1;
	dp[0] = 0;
	for(auto a : ed[0]) pq.push(a);
}

void ReceiveB(bool y) {
	if(y) {
		if(count < 11) node += 1 << count;
		else dis += 1 << (count - 11);
	}
	count++;
	if(count == 20) {
		count = 0;
		while(!pq.empty() && dp[pq.top().second] != -1) pq.pop();
		//if(pq.empty()) printf("B: pq empty\n");
		//else printf("B: pq.top() = (%d, %d)\n", pq.top().first, pq.top().second);
		if(node != 0 && (pq.empty() || lastdis + dis < pq.top().first)) {
			dp[node] = lastdis + dis;
			for(auto a : ed[node]) if(dp[a.second] == -1) pq.push(std::make_pair(dp[node] + a.first, a.second));
			send(node, dp[node] - lastdis);
			lastdis = dp[node];
		}
		else {
			//printf("B*\n");
			dp[pq.top().second] = pq.top().first;
			send(pq.top().second, pq.top().first - lastdis);
			lastdis = pq.top().first;
			for(auto a : ed[pq.top().second]) if(dp[a.second] == -1) pq.push(std::make_pair(dp[pq.top().second] + a.first, a.second));
		}
		node = dis = 0;
	}
}

Compilation message

Azer.cpp: In function 'void InitA(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
Azer.cpp:36:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < U.size(); i++) {
                 ~~^~~~~~~~~~

Baijan.cpp: In function 'void InitB(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
Baijan.cpp:27:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < S.size(); i++) {
                 ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 333 ms 776 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 2 ms 732 KB Unexpected end of file - int32 expected (Baijan)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 408 ms 668 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 560 ms 1432 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 560 ms 1432 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 560 ms 1432 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 333 ms 776 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -