Submission #296813

# Submission time Handle Problem Language Result Execution time Memory
296813 2020-09-10T22:15:34 Z Plurm Airline Route Map (JOI18_airline) C++11
22 / 100
831 ms 49260 KB
#include "Alicelib.h"
#include <bits/stdc++.h>
using namespace std;

int vg[1024][1024]; // virtual graph
void Alice( int N, int M, int A[], int B[] ){
	for(int i = 0; i < M; i++){
		if(A[i] > B[i]) swap(A[i], B[i]);
		vg[A[i]][B[i]] = 1;
	}
	for(int i = 0; i < N; i++){
		vg[i][N] = 1;
		for(int b = 0; b < 10; b++){
			if(i & (1 << b)){
				vg[i][N+1+b] = 1;
			}
		}
	}
	for(int i = 0; i < 5; i++){
		for(int j = 0; j < i; j++){
			vg[N+1+i][N+6+j] = 1;
		}
		vg[N+1+i][N+11] = 1;
	}
	vg[0][N+11] = 1;
	if(N <= 30) for(int i = N+12; i < 40; i++) vg[N][i] = 1;
	vector<pair<int,int> > ev;
	const int V = N <= 30 ? 40 : N+12;
	for(int i = 0; i < V; i++){
		for(int j = i+1; j < V; j++){
			if(vg[i][j]) ev.emplace_back(i,j);
		}
	}
	InitG(V, ev.size());
	for(int i = 0; i < ev.size(); i++){
		int x, y;
		tie(x, y) = ev[i];
		MakeG(i, x, y);
	}
}

#include "Boblib.h"
#include <bits/stdc++.h>
using namespace std;

static int bvg[1555][1555];
static bool isOriginal[1555];
static int p[1555];
void Bob( int V, int U, int C[], int D[] ){
	int N = V == 40 ? 0 : V - 12;
	memset(bvg, 0, sizeof(bvg));
	memset(isOriginal, 0, sizeof(isOriginal));
	memset(p, 0, sizeof(p));
	for(int i = 0; i < U; i++){
		bvg[C[i]][D[i]] = bvg[D[i]][C[i]] = 1;
	}
	int SIG = -1;
	int mx = -1;
	for(int i = 0; i < V; i++){
		isOriginal[i] = true;
		int cnt = 0;
		for(int j = 0; j < V; j++){
			cnt += bvg[i][j];
		}
		if(V == 40){
			if(cnt > mx){
				SIG = i;
				mx = cnt;
			}
		}else{
			if(cnt == N){
				SIG = i;
				mx = cnt;
			}
		}
	}
	N = 0;
	isOriginal[SIG] = false;
	vector<int> bits;
	for(int i = 0; i < V; i++){
		if(bvg[SIG][i] == 0 && i != SIG){
			bits.push_back(i);
			isOriginal[i] = false;
		}
	}
	if(bits.size() != 11) while(true);
	int BSIG = -1;
	int ZERO = -1;
	for(int i : bits){
		int chco = 0;
		int chci = 0;
		for(int j = 0; j < V; j++) if(bvg[i][j]) chco++;
		for(int j : bits) if(bvg[i][j]) chci++;
		if(chco == 6 && chci == 5) BSIG = i;
	}
	for(int i = 0; i < V; i++){
		if(bvg[SIG][i] && bvg[i][BSIG]){
			ZERO = i;
		}
	}
	bvg[BSIG][ZERO] = bvg[ZERO][BSIG] = 0;
	bits.erase(find(bits.begin(), bits.end(), BSIG));
	isOriginal[ZERO] = true;
	vector<int> leftbits, rightbits;
	for(int i : bits){
		if(bvg[BSIG][i]) leftbits.push_back(i);
		else rightbits.push_back(i);
		bvg[BSIG][i] = bvg[i][BSIG] = 0;
		int chc = 0;
		for(int j : bits) if(bvg[i][j]) chc++;
	}
	sort(leftbits.begin(), leftbits.end(), [&bits](int b1, int b2){
		int chc1 = 0;
		int chc2 = 0;
		for(int i : bits) if(bvg[b1][i]) chc1++;
		for(int i : bits) if(bvg[b2][i]) chc2++;
		return chc1 < chc2;
	});
	sort(rightbits.begin(), rightbits.end(), [&bits](int b1, int b2){
		int chc1 = 0;
		int chc2 = 0;
		for(int i : bits) if(bvg[b1][i]) chc1++;
		for(int i : bits) if(bvg[b2][i]) chc2++;
		return chc1 > chc2;
	});
	bits = leftbits;
	for(int x : rightbits) bits.push_back(x);
	for(int i = 0; i < 10; i++){
		p[bits[i]] = N+1+i;
	}
	for(int i = 0; i < V; i++){
		if(isOriginal[i] && i != ZERO){
			int name = 0;
			for(int j = 0; j < 10; j++){
				if(bvg[i][bits[j]]) name += 1 << j;
			}
			p[i] = name;
			if(name == 0) isOriginal[i] = false;
			else N++;
		}else if(i == ZERO) N++;
	}
	vector<pair<int,int> > ev;
	for(int i = 0; i < U; i++){
		if(isOriginal[C[i]] && isOriginal[D[i]]){
			ev.emplace_back(p[C[i]], p[D[i]]);
		}
	}
	InitMap(N, ev.size());
	for(auto p : ev){
		MakeMap(p.first, p.second);
	}
}

Compilation message

Alice.cpp: In function 'void Alice(int, int, int*, int*)':
Alice.cpp:35:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |  for(int i = 0; i < ev.size(); i++){
      |                 ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 12 ms 14384 KB Output is correct
2 Correct 13 ms 14388 KB Output is correct
3 Correct 12 ms 14396 KB Output is correct
4 Correct 12 ms 14336 KB Output is correct
5 Correct 12 ms 14208 KB Output is correct
6 Correct 13 ms 14336 KB Output is correct
7 Correct 12 ms 14512 KB Output is correct
8 Correct 12 ms 14336 KB Output is correct
9 Correct 12 ms 14348 KB Output is correct
10 Correct 12 ms 14392 KB Output is correct
11 Correct 12 ms 14336 KB Output is correct
12 Correct 12 ms 14336 KB Output is correct
13 Correct 12 ms 14392 KB Output is correct
14 Correct 12 ms 14384 KB Output is correct
15 Correct 12 ms 14384 KB Output is correct
16 Correct 12 ms 14336 KB Output is correct
17 Correct 13 ms 14392 KB Output is correct
18 Correct 12 ms 14384 KB Output is correct
19 Correct 14 ms 14208 KB Output is correct
20 Correct 12 ms 14388 KB Output is correct
21 Correct 12 ms 14336 KB Output is correct
22 Correct 12 ms 14336 KB Output is correct
23 Correct 12 ms 14336 KB Output is correct
24 Correct 12 ms 14408 KB Output is correct
25 Correct 12 ms 14404 KB Output is correct
26 Correct 12 ms 14336 KB Output is correct
27 Correct 12 ms 14400 KB Output is correct
28 Correct 13 ms 14336 KB Output is correct
29 Correct 12 ms 14336 KB Output is correct
30 Correct 12 ms 14336 KB Output is correct
31 Correct 12 ms 14400 KB Output is correct
32 Correct 12 ms 14592 KB Output is correct
33 Correct 12 ms 14336 KB Output is correct
34 Correct 12 ms 14396 KB Output is correct
35 Correct 12 ms 14336 KB Output is correct
36 Correct 12 ms 14336 KB Output is correct
37 Correct 12 ms 14336 KB Output is correct
38 Correct 12 ms 14336 KB Output is correct
39 Correct 12 ms 14336 KB Output is correct
40 Correct 13 ms 14336 KB Output is correct
41 Correct 12 ms 14336 KB Output is correct
42 Correct 12 ms 14392 KB Output is correct
43 Correct 12 ms 14380 KB Output is correct
44 Correct 12 ms 14404 KB Output is correct
45 Correct 12 ms 14496 KB Output is correct
46 Correct 12 ms 14384 KB Output is correct
47 Correct 12 ms 14336 KB Output is correct
48 Correct 12 ms 14640 KB Output is correct
49 Correct 12 ms 14392 KB Output is correct
50 Correct 13 ms 14336 KB Output is correct
51 Correct 12 ms 14336 KB Output is correct
52 Correct 12 ms 14336 KB Output is correct
53 Correct 12 ms 14336 KB Output is correct
54 Correct 12 ms 14428 KB Output is correct
55 Correct 12 ms 14208 KB Output is correct
56 Correct 12 ms 14416 KB Output is correct
57 Correct 13 ms 14208 KB Output is correct
58 Correct 12 ms 14464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 14384 KB Output is correct
2 Correct 13 ms 14388 KB Output is correct
3 Correct 12 ms 14396 KB Output is correct
4 Correct 12 ms 14336 KB Output is correct
5 Correct 12 ms 14208 KB Output is correct
6 Correct 13 ms 14336 KB Output is correct
7 Correct 12 ms 14512 KB Output is correct
8 Correct 12 ms 14336 KB Output is correct
9 Correct 12 ms 14348 KB Output is correct
10 Correct 12 ms 14392 KB Output is correct
11 Correct 12 ms 14336 KB Output is correct
12 Correct 12 ms 14336 KB Output is correct
13 Correct 12 ms 14392 KB Output is correct
14 Correct 12 ms 14384 KB Output is correct
15 Correct 12 ms 14384 KB Output is correct
16 Correct 12 ms 14336 KB Output is correct
17 Correct 13 ms 14392 KB Output is correct
18 Correct 12 ms 14384 KB Output is correct
19 Correct 14 ms 14208 KB Output is correct
20 Correct 12 ms 14388 KB Output is correct
21 Correct 12 ms 14336 KB Output is correct
22 Correct 12 ms 14336 KB Output is correct
23 Correct 12 ms 14336 KB Output is correct
24 Correct 12 ms 14408 KB Output is correct
25 Correct 12 ms 14404 KB Output is correct
26 Correct 12 ms 14336 KB Output is correct
27 Correct 12 ms 14400 KB Output is correct
28 Correct 13 ms 14336 KB Output is correct
29 Correct 12 ms 14336 KB Output is correct
30 Correct 12 ms 14336 KB Output is correct
31 Correct 12 ms 14400 KB Output is correct
32 Correct 12 ms 14592 KB Output is correct
33 Correct 12 ms 14336 KB Output is correct
34 Correct 12 ms 14396 KB Output is correct
35 Correct 12 ms 14336 KB Output is correct
36 Correct 12 ms 14336 KB Output is correct
37 Correct 12 ms 14336 KB Output is correct
38 Correct 12 ms 14336 KB Output is correct
39 Correct 12 ms 14336 KB Output is correct
40 Correct 13 ms 14336 KB Output is correct
41 Correct 12 ms 14336 KB Output is correct
42 Correct 12 ms 14392 KB Output is correct
43 Correct 12 ms 14380 KB Output is correct
44 Correct 12 ms 14404 KB Output is correct
45 Correct 12 ms 14496 KB Output is correct
46 Correct 12 ms 14384 KB Output is correct
47 Correct 12 ms 14336 KB Output is correct
48 Correct 12 ms 14640 KB Output is correct
49 Correct 12 ms 14392 KB Output is correct
50 Correct 13 ms 14336 KB Output is correct
51 Correct 12 ms 14336 KB Output is correct
52 Correct 12 ms 14336 KB Output is correct
53 Correct 12 ms 14336 KB Output is correct
54 Correct 12 ms 14428 KB Output is correct
55 Correct 12 ms 14208 KB Output is correct
56 Correct 12 ms 14416 KB Output is correct
57 Correct 13 ms 14208 KB Output is correct
58 Correct 12 ms 14464 KB Output is correct
59 Correct 13 ms 14464 KB Output is correct
60 Correct 13 ms 14464 KB Output is correct
61 Correct 12 ms 14464 KB Output is correct
62 Correct 12 ms 14528 KB Output is correct
63 Correct 12 ms 14464 KB Output is correct
64 Correct 12 ms 14512 KB Output is correct
65 Correct 14 ms 14500 KB Output is correct
66 Runtime error 26 ms 25520 KB Execution killed with signal 11 (could be triggered by violating memory limits)
67 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 831 ms 38712 KB Output is correct : V - N = 12
2 Correct 531 ms 34908 KB Output is correct : V - N = 12
3 Correct 209 ms 25284 KB Output is correct : V - N = 12
4 Correct 27 ms 18748 KB Output is correct : V - N = 12
5 Correct 168 ms 22432 KB Output is correct : V - N = 12
6 Correct 452 ms 32880 KB Output is correct : V - N = 12
7 Correct 783 ms 38288 KB Output is correct : V - N = 12
8 Correct 587 ms 36572 KB Output is correct : V - N = 12
9 Correct 297 ms 27372 KB Output is correct : V - N = 12
10 Correct 55 ms 19744 KB Output is correct : V - N = 12
11 Correct 100 ms 20576 KB Output is correct : V - N = 12
12 Correct 411 ms 28592 KB Output is correct : V - N = 12
13 Correct 721 ms 37456 KB Output is correct : V - N = 12
14 Correct 709 ms 37748 KB Output is correct : V - N = 12
15 Correct 552 ms 31740 KB Output is correct : V - N = 12
16 Correct 95 ms 21100 KB Output is correct : V - N = 12
17 Correct 34 ms 19328 KB Output is correct : V - N = 12
18 Correct 261 ms 26452 KB Output is correct : V - N = 12
19 Correct 681 ms 35988 KB Output is correct : V - N = 12
20 Runtime error 828 ms 49260 KB Execution killed with signal 11 (could be triggered by violating memory limits)
21 Halted 0 ms 0 KB -