Submission #331835

# Submission time Handle Problem Language Result Execution time Memory
331835 2020-11-30T11:30:38 Z pit4h Airline Route Map (JOI18_airline) C++14
0 / 100
675 ms 29820 KB
#include<bits/stdc++.h>
#include "Alicelib.h"
using namespace std;
#define st first
#define nd second
#define mp make_pair
using pii = pair<int, int>;
const int MAXN = 1020;
int deg[MAXN];
vector<pii> edge;
void Alice( int N, int M, int A[], int B[] ){
	for(int i=0; i<M; ++i) {
		edge.push_back(mp(A[i], B[i]));
		deg[A[i]]++;
		deg[B[i]]++;
	}
	for(int i=0; i<N; ++i) {
		if(!deg[i]) continue;
		for(int j=0; j<10; ++j) {
			if((1<<j)&i) {
				edge.push_back(mp(i, N+j));
			}
		}
	}
	for(int i=0; i<10; ++i) {
		edge.push_back(mp(N+10, N+i));
	}
	for(int i=0; i<5; ++i) {
		for(int j=9; j>=9-i; --j) {
			edge.push_back(mp(N+i, N+j));
		}
	}
	edge.push_back(mp(N+11, N+10));

	InitG(N+12, edge.size());
	for(int i=0; i<(int)edge.size(); ++i) {
		MakeG(i, edge[i].st, edge[i].nd);
	}
}

#include "Boblib.h"
#include<bits/stdc++.h>
using namespace std;
#define st first
#define nd second
#define mp make_pair
using pii = pair<int, int>;
const int MAXN = 1020;
int N;
int root, bits[MAXN], first_bit, id[MAXN];
bool node[MAXN], is_bit[MAXN], sec_half[MAXN];
vector<int> g[MAXN], gb[MAXN];
vector<pii> edges;

void Bob( int V, int U, int C[], int D[] ){
	N = V - 12;
	for(int i=0; i<U; ++i) {
		g[C[i]].push_back(D[i]);
		g[D[i]].push_back(C[i]);
	}
	for(int i=0; i<V; ++i) {
		node[i] = 1;
		if((int)g[i].size()==1) {
			root = i;
			node[i] = 0;
		}
	}
	int spec = g[root][0];
	node[spec] = 0;
	for(int i: g[spec]) {
		if(i == root) continue;
		is_bit[i] = 1;
		node[i] = 0;
	}
	for(int i=0; i<U; ++i) {
		if(is_bit[C[i]] && is_bit[D[i]]) {
			gb[C[i]].push_back(D[i]);
			gb[D[i]].push_back(C[i]);
		}
	}
	for(int i=0; i<V; ++i) {
		if((int)gb[i].size()==1 && (int)g[i].size() >= N/2+2) {
			first_bit = i;
		}
	}
	for(int i: gb[first_bit]) {
		sec_half[i] = 1;
	}
	for(int i=0; i<V; ++i) {
		if(!is_bit[i]) continue;
		int num = gb[i].size();
		if(!sec_half[i]) {
			bits[i] = num-1;
		}
		else {
			bits[i] = 5+num-1;
		}
	}
	
	for(int i=0; i<V; ++i) {
		if(!node[i]) continue;
		for(int j: g[i]) {
			if(is_bit[j]) {
				id[i] += (1<<bits[j]);
			}
		}
	}
	for(int i=0; i<U; ++i) {
		if(node[C[i]] && node[D[i]]) edges.push_back(mp(id[C[i]], id[D[i]]));
	}
	InitMap(V-12, edges.size());
	for(auto i: edges) {
		MakeMap(i.st, i.nd);	
	}
}

# Verdict Execution time Memory Grader output
1 Correct 5 ms 4832 KB Output is correct
2 Correct 5 ms 4960 KB Output is correct
3 Incorrect 5 ms 4832 KB Wrong Answer [11]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4832 KB Output is correct
2 Correct 5 ms 4960 KB Output is correct
3 Incorrect 5 ms 4832 KB Wrong Answer [11]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 675 ms 29820 KB Wrong Answer [12]
2 Halted 0 ms 0 KB -