답안 #296755

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
296755 2020-09-10T20:57:42 Z Plurm 항공 노선도 (JOI18_airline) C++11
22 / 100
2500 ms 38856 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 <= 10) for(int i = N+12; i < N+22; i++) vg[N][i] = 1;
	vector<pair<int,int> > ev;
	const int V = N <= 10 ? N+22 : 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 = 0;
	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(cnt > mx){
			SIG = i;
			mx = cnt;
		}
	}
	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;
		}
	}
	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;
	}
	if(BSIG == -1) while(true);
	for(int i = 0; i < V; i++){
		if(bvg[SIG][i] && bvg[i][BSIG]){
			ZERO = i;
		}
	}
	if(ZERO == -1) while(true);
	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++){
      |                 ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 14336 KB Output is correct
2 Correct 12 ms 14336 KB Output is correct
3 Correct 12 ms 14392 KB Output is correct
4 Correct 13 ms 14592 KB Output is correct
5 Correct 11 ms 14416 KB Output is correct
6 Correct 11 ms 14336 KB Output is correct
7 Correct 12 ms 14336 KB Output is correct
8 Correct 12 ms 14336 KB Output is correct
9 Correct 12 ms 14388 KB Output is correct
10 Correct 12 ms 14464 KB Output is correct
11 Correct 12 ms 14336 KB Output is correct
12 Correct 12 ms 14496 KB Output is correct
13 Correct 12 ms 14336 KB Output is correct
14 Correct 12 ms 14392 KB Output is correct
15 Correct 12 ms 14336 KB Output is correct
16 Correct 12 ms 14392 KB Output is correct
17 Correct 12 ms 14392 KB Output is correct
18 Correct 12 ms 14396 KB Output is correct
19 Correct 12 ms 14380 KB Output is correct
20 Correct 12 ms 14384 KB Output is correct
21 Correct 12 ms 14336 KB Output is correct
22 Correct 12 ms 14464 KB Output is correct
23 Correct 11 ms 14392 KB Output is correct
24 Correct 12 ms 14336 KB Output is correct
25 Correct 12 ms 14388 KB Output is correct
26 Correct 12 ms 14336 KB Output is correct
27 Correct 13 ms 14400 KB Output is correct
28 Correct 12 ms 14388 KB Output is correct
29 Correct 14 ms 14336 KB Output is correct
30 Correct 12 ms 14336 KB Output is correct
31 Correct 12 ms 14336 KB Output is correct
32 Correct 12 ms 14404 KB Output is correct
33 Correct 11 ms 14432 KB Output is correct
34 Correct 12 ms 14624 KB Output is correct
35 Correct 12 ms 14392 KB Output is correct
36 Correct 12 ms 14336 KB Output is correct
37 Correct 11 ms 14388 KB Output is correct
38 Correct 13 ms 14336 KB Output is correct
39 Correct 12 ms 14384 KB Output is correct
40 Correct 12 ms 14208 KB Output is correct
41 Correct 12 ms 14348 KB Output is correct
42 Correct 12 ms 14336 KB Output is correct
43 Correct 11 ms 14336 KB Output is correct
44 Correct 12 ms 14336 KB Output is correct
45 Correct 12 ms 14336 KB Output is correct
46 Correct 12 ms 14336 KB Output is correct
47 Correct 13 ms 14336 KB Output is correct
48 Correct 12 ms 14392 KB Output is correct
49 Correct 12 ms 14396 KB Output is correct
50 Correct 12 ms 14400 KB Output is correct
51 Correct 11 ms 14432 KB Output is correct
52 Correct 12 ms 14208 KB Output is correct
53 Correct 12 ms 14436 KB Output is correct
54 Correct 11 ms 14336 KB Output is correct
55 Correct 12 ms 14336 KB Output is correct
56 Correct 13 ms 14412 KB Output is correct
57 Correct 12 ms 14416 KB Output is correct
58 Correct 12 ms 14336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 14336 KB Output is correct
2 Correct 12 ms 14336 KB Output is correct
3 Correct 12 ms 14392 KB Output is correct
4 Correct 13 ms 14592 KB Output is correct
5 Correct 11 ms 14416 KB Output is correct
6 Correct 11 ms 14336 KB Output is correct
7 Correct 12 ms 14336 KB Output is correct
8 Correct 12 ms 14336 KB Output is correct
9 Correct 12 ms 14388 KB Output is correct
10 Correct 12 ms 14464 KB Output is correct
11 Correct 12 ms 14336 KB Output is correct
12 Correct 12 ms 14496 KB Output is correct
13 Correct 12 ms 14336 KB Output is correct
14 Correct 12 ms 14392 KB Output is correct
15 Correct 12 ms 14336 KB Output is correct
16 Correct 12 ms 14392 KB Output is correct
17 Correct 12 ms 14392 KB Output is correct
18 Correct 12 ms 14396 KB Output is correct
19 Correct 12 ms 14380 KB Output is correct
20 Correct 12 ms 14384 KB Output is correct
21 Correct 12 ms 14336 KB Output is correct
22 Correct 12 ms 14464 KB Output is correct
23 Correct 11 ms 14392 KB Output is correct
24 Correct 12 ms 14336 KB Output is correct
25 Correct 12 ms 14388 KB Output is correct
26 Correct 12 ms 14336 KB Output is correct
27 Correct 13 ms 14400 KB Output is correct
28 Correct 12 ms 14388 KB Output is correct
29 Correct 14 ms 14336 KB Output is correct
30 Correct 12 ms 14336 KB Output is correct
31 Correct 12 ms 14336 KB Output is correct
32 Correct 12 ms 14404 KB Output is correct
33 Correct 11 ms 14432 KB Output is correct
34 Correct 12 ms 14624 KB Output is correct
35 Correct 12 ms 14392 KB Output is correct
36 Correct 12 ms 14336 KB Output is correct
37 Correct 11 ms 14388 KB Output is correct
38 Correct 13 ms 14336 KB Output is correct
39 Correct 12 ms 14384 KB Output is correct
40 Correct 12 ms 14208 KB Output is correct
41 Correct 12 ms 14348 KB Output is correct
42 Correct 12 ms 14336 KB Output is correct
43 Correct 11 ms 14336 KB Output is correct
44 Correct 12 ms 14336 KB Output is correct
45 Correct 12 ms 14336 KB Output is correct
46 Correct 12 ms 14336 KB Output is correct
47 Correct 13 ms 14336 KB Output is correct
48 Correct 12 ms 14392 KB Output is correct
49 Correct 12 ms 14396 KB Output is correct
50 Correct 12 ms 14400 KB Output is correct
51 Correct 11 ms 14432 KB Output is correct
52 Correct 12 ms 14208 KB Output is correct
53 Correct 12 ms 14436 KB Output is correct
54 Correct 11 ms 14336 KB Output is correct
55 Correct 12 ms 14336 KB Output is correct
56 Correct 13 ms 14412 KB Output is correct
57 Correct 12 ms 14416 KB Output is correct
58 Correct 12 ms 14336 KB Output is correct
59 Execution timed out 3041 ms 14336 KB Time limit exceeded
60 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3759 ms 38856 KB Time limit exceeded
2 Halted 0 ms 0 KB -