Submission #362652

# Submission time Handle Problem Language Result Execution time Memory
362652 2021-02-04T00:08:01 Z LucaDantas Airline Route Map (JOI18_airline) C++17
0 / 100
659 ms 14940 KB
#include "Alicelib.h"
#include <cassert>
#include <cstdio>

constexpr int maxn = 1510;

int C[maxn], D[maxn];

bool on(int a, int b) {return a&(1<<b);}

void Alice( int N, int M, int A[], int B[] ){
	if(N <= 2) {
		InitG(N, M);
		for(int i = 0; i < M; i++)
			MakeG(i, A[i], B[i]);
		return;
	}
	for(int i = 0; i < M; i++)
		C[i] = A[i], D[i] = B[i];
	for(int i = 0; i < N; i++, M++)
		C[M] = N, D[M] = i;
	
	for(int i = 0; i < N; i++)
		for(int j = 0; j < 10; j++)
			if(on(i+1, j)) C[M] = N+1+j, D[M++] = i;
	
	for(int j = 0; j < 9; j++)
		C[M] = N+1+j, D[M++] = N+1+j+1;
	C[M] = N+11, D[M++] = N;

	InitG(N+12, M);
	for(int i = 0; i < M; i++)
		MakeG(i, C[i], D[i]);
}
#include "Boblib.h"
#include<vector>
#include <cassert>
#include <cstdio>

#define pb push_back

constexpr int maxn = 1510;

std::vector<int> g[maxn];

int val[maxn];

bool mark[maxn], vis[maxn];

void Bob( int V, int U, int C[], int D[] ){
	if(V <= 2) {
		InitMap(V, U);
		for(int i = 0; i < U; i++)
			MakeMap(C[i], D[i]);
		return;
	}
	for(int i = 0; i < U; i++)
		g[C[i]].pb(D[i]), g[D[i]].pb(C[i]);
	std::vector<int> opa;
	int mx = -1;
	for(int i = 0; i < V; i++)
		if((int)g[i].size() == 1)
			opa.pb(i);
	int N = V-12;
	for(int x : opa) {
		if((int)g[g[x][0]].size() == N+1)
			assert(mx != -1), mx = g[x][0];
	}

	for(int v : g[mx])
		mark[v] = 1;

	std::vector<int> a, b;
	for(int i = 0; i < V; i++)
		if(!mark[i] && i != mx)
			a.pb(i);

	for(int x : a) {
		int cnt = 0;
		for(int v : g[x])
			if(!mark[v]) ++cnt;
		if(cnt == 1) b.pb(x);
	}
	// assert((int)b.size() <= 2);
	int now = -1;
	if((int)b.size() == 1) now = b[0];
	else {
		if(g[b[0]].size() > g[b[1]].size())
			now = b[0];
		else now = b[1];
	}

	int pos = 0;
	while(1) {
		for(int v : g[now])
			if(mark[v]) val[v] += 1<<pos, --U;
		++pos;
		int ok = 0;
		vis[now] = 1;
		for(int v : g[now])
			if(!mark[v] && !vis[v]) {now = v; ok = 1; break;}
		if(!ok) break;
	}
	InitMap(N, U - N - 10);
	for(int i = 0; i < V; i++) {
		if(!val[i]) continue;
		for(int v : g[i])
			if(val[v] && val[i] > val[v])
				MakeMap(val[i]-1, val[v]-1);
	}
}

# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 6112 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 6112 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 659 ms 14940 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -