Submission #315773

# Submission time Handle Problem Language Result Execution time Memory
315773 2020-10-23T23:45:58 Z bigg Airline Route Map (JOI18_airline) C++14
37 / 100
526 ms 23288 KB
#include "Alicelib.h"
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1010;
static vector<int> grafo[MAXN], vgrafo[1505];
static int marc[1505][1505];
void Alice( int N, int M, int A[], int B[] ){
	for(int i = 0; i < M; i++) {
		grafo[A[i]].push_back(B[i]);
		grafo[B[i]].push_back(A[i]);
	}
	if(N == 1){
		InitG(1, 0);
		return;
	}
	int n = 0, m = 0;
	n++;
	n++;
	for(auto u : grafo[0]){
		if(u == 1){
			vgrafo[0].push_back(1);
			vgrafo[1].push_back(0);
			m++;
		}
	}
	for(int i = 2; i < N; i++){
		int r = n;
		int con = n + 1;
		n++;
		vgrafo[r].push_back(n);
		vgrafo[n].push_back(r);
		m++;
		n++;
		vgrafo[con].push_back(n);
		vgrafo[n].push_back(con);
		m++;
		
		n++;
		vgrafo[r].push_back(n);
		vgrafo[n].push_back(r);
		m++;
		vgrafo[con].push_back(n);
		vgrafo[n].push_back(con);
		m++;
		n++;
		vgrafo[r].push_back(n);
		vgrafo[n].push_back(r);
		m++;
		vgrafo[con].push_back(n);
		vgrafo[n].push_back(con);
		m++;
		
		
		for(auto u : grafo[i]){
			if(u == 0){
				vgrafo[n].push_back(n-1);
				vgrafo[n-1].push_back(n);
				m++;
			}
		}
		vector<int> qual;
		qual.push_back(r);
		for(int j = 1; j <= i; j++){
			n++;
			vgrafo[qual[j-1]].push_back(n);
			vgrafo[n].push_back(qual[j-1]);
			m++;
			qual.push_back(n);
		}
		for(auto u : grafo[i]){
			if(u == 0 || u > i) continue;
			
			vgrafo[qual[u]].push_back(con);
			vgrafo[con].push_back(qual[u]);
			m++;
		}
		vgrafo[qual[i]].push_back(con);
		vgrafo[con].push_back(qual[i]);
		m++;
		n++;
	}
	if(n == 0){
		InitG(1, 0);
		return;
	}
	InitG(n, m);
	int it = 0;
	for(int i = 0; i <= n; i++){
		for(auto u : vgrafo[i]){
			if(!marc[i][u]){
				MakeG(it, i, u);
				it++;
				marc[i][u] = 1;
				marc[u][i] = 1;
			}
		}	

	}

}

#include "Boblib.h"
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1010;
static vector<int> vgrafo[1505];
static vector<pair<int, int> > grafo;
static int marc1[1505][1505], marc2[1505][1505];
static int marc[1505];
int dfs(int x, int p, int h, int con){
	int maxh = h;
	for(int i = 0; i < vgrafo[x].size(); i++){
		int viz = vgrafo[x][i];
		if(viz == p || viz == con) continue;
		maxh = max(maxh, dfs(viz, x, h + 1, con));

	}
	return maxh;
}

void Bob( int V, int U, int C[], int D[] ){
	if(V == 1){
		InitMap(1, 0);
		return;
	}
	bool okk= 0;
	if(V == 2){
		if(U != 0){
			InitMap(2, 1);
			MakeMap(1, 0);
		}
		else{
			InitMap(2,0);
		}
		return;
	}
	for(int i = 0; i < U; i++ ){
		vgrafo[C[i]].push_back(D[i]);
		vgrafo[D[i]].push_back(C[i]);
		//printf("%d %d\n", C[i], D[i]);
	}
	int n = 1, m = 0;
	for(int i = 0; i < V; i++){
		//printf("%d\n", i);
		if(vgrafo[i].size() == 1 ){
			if(vgrafo[vgrafo[i][0]].size() == 1 &&!okk){
				n = max(n, 2);
				grafo.push_back(make_pair(1, 0));
				m++;
				okk = 1;
			}
		}
		if(vgrafo[i].size() != 4) continue;
		
		int esse = 1;
		int con;
		int vizini, isconec = 0;;
		for(auto u : vgrafo[i]){
			marc[u] = 1;
			if(vgrafo[u].size() > 4) con = u;
		}
		marc[i] = 1;
		for(auto u : vgrafo[i]){
			bool ok = 0;
			for(auto v : vgrafo[u]){
				if(!marc[v]) ok = 1;
			}
			if(ok && u != con){
				vizini = u;
				break;

			}
		}
		for(auto u : vgrafo[i]){
			if(vizini == u || con == u) continue;
			if(vgrafo[u].size() == 3) isconec = 1;
		}
		esse = dfs(vizini, i, 1, con);
		n = max(esse, n);
		if(isconec){
			grafo.push_back(make_pair(esse, 0));
			//printf("GREAL %d %d\n",  esse, 0);
			m++;
		}
		if(esse == 1) continue;
		if(esse == 0){
			printf("ESSERUIM\n");
		}
		int ult = i;
		for(int j = 1; j < esse; j++){
			if(vgrafo[vizini].size() > 2){
				grafo.push_back(make_pair(esse, j));
			//printf("GREAL %d %d\n",  esse, 0);
				m++;
			}
			for(auto u : vgrafo[vizini]){
				if(vgrafo[u].size() > 1 && u != ult && u != con){
					ult = vizini;
					vizini = u;
					break;
				}
			}
		}

	}
	//printf("%d\n",m );
	InitMap(n + 1, m);
	for(int i = 0; i < m; i++){
		MakeMap(grafo[i].first, grafo[i].second);
	}

}

Compilation message

Bob.cpp: In function 'int dfs(int, int, int, int)':
Bob.cpp:11:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |  for(int i = 0; i < vgrafo[x].size(); i++){
      |                 ~~^~~~~~~~~~~~~~~~~~
Bob.cpp: At global scope:
Bob.cpp:7:31: warning: 'marc2' defined but not used [-Wunused-variable]
    7 | static int marc1[1505][1505], marc2[1505][1505];
      |                               ^~~~~
Bob.cpp:7:12: warning: 'marc1' defined but not used [-Wunused-variable]
    7 | static int marc1[1505][1505], marc2[1505][1505];
      |            ^~~~~
Bob.cpp: In function 'void Bob(int, int, int*, int*)':
Bob.cpp:77:13: warning: 'vizini' may be used uninitialized in this function [-Wmaybe-uninitialized]
   77 |   esse = dfs(vizini, i, 1, con);
      |          ~~~^~~~~~~~~~~~~~~~~~~
Bob.cpp:77:13: warning: 'con' may be used uninitialized in this function [-Wmaybe-uninitialized]
# Verdict Execution time Memory Grader output
1 Correct 7 ms 7680 KB Output is correct
2 Correct 7 ms 7680 KB Output is correct
3 Correct 7 ms 7680 KB Output is correct
4 Correct 7 ms 7680 KB Output is correct
5 Correct 7 ms 7680 KB Output is correct
6 Correct 7 ms 7680 KB Output is correct
7 Correct 7 ms 7680 KB Output is correct
8 Correct 7 ms 7680 KB Output is correct
9 Correct 7 ms 7680 KB Output is correct
10 Correct 7 ms 7936 KB Output is correct
11 Correct 7 ms 7680 KB Output is correct
12 Correct 7 ms 7680 KB Output is correct
13 Correct 7 ms 7680 KB Output is correct
14 Correct 7 ms 7680 KB Output is correct
15 Correct 8 ms 7424 KB Output is correct
16 Correct 7 ms 7680 KB Output is correct
17 Correct 7 ms 7680 KB Output is correct
18 Correct 7 ms 7680 KB Output is correct
19 Correct 7 ms 7680 KB Output is correct
20 Correct 7 ms 7680 KB Output is correct
21 Correct 7 ms 7424 KB Output is correct
22 Correct 7 ms 7424 KB Output is correct
23 Correct 7 ms 7424 KB Output is correct
24 Correct 8 ms 7168 KB Output is correct
25 Correct 7 ms 7168 KB Output is correct
26 Correct 7 ms 7168 KB Output is correct
27 Correct 8 ms 7424 KB Output is correct
28 Correct 7 ms 7424 KB Output is correct
29 Correct 7 ms 7424 KB Output is correct
30 Correct 7 ms 7424 KB Output is correct
31 Correct 7 ms 7680 KB Output is correct
32 Correct 7 ms 7680 KB Output is correct
33 Correct 7 ms 7680 KB Output is correct
34 Correct 7 ms 7680 KB Output is correct
35 Correct 7 ms 7680 KB Output is correct
36 Correct 7 ms 7680 KB Output is correct
37 Correct 7 ms 7680 KB Output is correct
38 Correct 7 ms 7680 KB Output is correct
39 Correct 7 ms 7680 KB Output is correct
40 Correct 7 ms 7680 KB Output is correct
41 Correct 7 ms 7680 KB Output is correct
42 Correct 8 ms 7680 KB Output is correct
43 Correct 7 ms 7680 KB Output is correct
44 Correct 7 ms 7680 KB Output is correct
45 Correct 7 ms 7680 KB Output is correct
46 Correct 8 ms 7680 KB Output is correct
47 Correct 7 ms 7680 KB Output is correct
48 Correct 7 ms 7680 KB Output is correct
49 Correct 7 ms 7680 KB Output is correct
50 Correct 7 ms 7680 KB Output is correct
51 Correct 7 ms 6912 KB Output is correct
52 Correct 7 ms 6912 KB Output is correct
53 Correct 7 ms 6912 KB Output is correct
54 Correct 7 ms 6912 KB Output is correct
55 Correct 8 ms 6912 KB Output is correct
56 Correct 7 ms 7168 KB Output is correct
57 Correct 7 ms 7168 KB Output is correct
58 Correct 7 ms 7168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 7680 KB Output is correct
2 Correct 7 ms 7680 KB Output is correct
3 Correct 7 ms 7680 KB Output is correct
4 Correct 7 ms 7680 KB Output is correct
5 Correct 7 ms 7680 KB Output is correct
6 Correct 7 ms 7680 KB Output is correct
7 Correct 7 ms 7680 KB Output is correct
8 Correct 7 ms 7680 KB Output is correct
9 Correct 7 ms 7680 KB Output is correct
10 Correct 7 ms 7936 KB Output is correct
11 Correct 7 ms 7680 KB Output is correct
12 Correct 7 ms 7680 KB Output is correct
13 Correct 7 ms 7680 KB Output is correct
14 Correct 7 ms 7680 KB Output is correct
15 Correct 8 ms 7424 KB Output is correct
16 Correct 7 ms 7680 KB Output is correct
17 Correct 7 ms 7680 KB Output is correct
18 Correct 7 ms 7680 KB Output is correct
19 Correct 7 ms 7680 KB Output is correct
20 Correct 7 ms 7680 KB Output is correct
21 Correct 7 ms 7424 KB Output is correct
22 Correct 7 ms 7424 KB Output is correct
23 Correct 7 ms 7424 KB Output is correct
24 Correct 8 ms 7168 KB Output is correct
25 Correct 7 ms 7168 KB Output is correct
26 Correct 7 ms 7168 KB Output is correct
27 Correct 8 ms 7424 KB Output is correct
28 Correct 7 ms 7424 KB Output is correct
29 Correct 7 ms 7424 KB Output is correct
30 Correct 7 ms 7424 KB Output is correct
31 Correct 7 ms 7680 KB Output is correct
32 Correct 7 ms 7680 KB Output is correct
33 Correct 7 ms 7680 KB Output is correct
34 Correct 7 ms 7680 KB Output is correct
35 Correct 7 ms 7680 KB Output is correct
36 Correct 7 ms 7680 KB Output is correct
37 Correct 7 ms 7680 KB Output is correct
38 Correct 7 ms 7680 KB Output is correct
39 Correct 7 ms 7680 KB Output is correct
40 Correct 7 ms 7680 KB Output is correct
41 Correct 7 ms 7680 KB Output is correct
42 Correct 8 ms 7680 KB Output is correct
43 Correct 7 ms 7680 KB Output is correct
44 Correct 7 ms 7680 KB Output is correct
45 Correct 7 ms 7680 KB Output is correct
46 Correct 8 ms 7680 KB Output is correct
47 Correct 7 ms 7680 KB Output is correct
48 Correct 7 ms 7680 KB Output is correct
49 Correct 7 ms 7680 KB Output is correct
50 Correct 7 ms 7680 KB Output is correct
51 Correct 7 ms 6912 KB Output is correct
52 Correct 7 ms 6912 KB Output is correct
53 Correct 7 ms 6912 KB Output is correct
54 Correct 7 ms 6912 KB Output is correct
55 Correct 8 ms 6912 KB Output is correct
56 Correct 7 ms 7168 KB Output is correct
57 Correct 7 ms 7168 KB Output is correct
58 Correct 7 ms 7168 KB Output is correct
59 Correct 9 ms 14848 KB Output is correct
60 Correct 11 ms 14848 KB Output is correct
61 Correct 10 ms 15104 KB Output is correct
62 Correct 9 ms 14848 KB Output is correct
63 Correct 9 ms 14848 KB Output is correct
64 Correct 9 ms 14848 KB Output is correct
65 Correct 9 ms 14848 KB Output is correct
66 Correct 9 ms 14848 KB Output is correct
67 Correct 9 ms 14848 KB Output is correct
68 Correct 9 ms 14848 KB Output is correct
69 Correct 9 ms 14848 KB Output is correct
70 Correct 10 ms 14848 KB Output is correct
71 Correct 10 ms 14848 KB Output is correct
72 Correct 11 ms 14848 KB Output is correct
73 Correct 10 ms 14848 KB Output is correct
74 Correct 10 ms 14848 KB Output is correct
75 Correct 9 ms 14848 KB Output is correct
76 Correct 9 ms 14848 KB Output is correct
77 Correct 9 ms 14848 KB Output is correct
78 Correct 11 ms 15104 KB Output is correct
79 Correct 9 ms 12096 KB Output is correct
80 Correct 8 ms 12032 KB Output is correct
81 Correct 8 ms 12544 KB Output is correct
82 Correct 8 ms 12288 KB Output is correct
83 Correct 8 ms 12288 KB Output is correct
84 Correct 8 ms 12544 KB Output is correct
85 Correct 9 ms 12544 KB Output is correct
86 Correct 9 ms 12544 KB Output is correct
87 Correct 8 ms 12288 KB Output is correct
88 Correct 9 ms 12288 KB Output is correct
89 Correct 9 ms 14912 KB Output is correct
90 Correct 9 ms 14848 KB Output is correct
91 Correct 9 ms 14848 KB Output is correct
92 Correct 9 ms 14848 KB Output is correct
93 Correct 9 ms 14848 KB Output is correct
94 Correct 10 ms 14848 KB Output is correct
95 Correct 9 ms 14848 KB Output is correct
96 Correct 10 ms 14848 KB Output is correct
97 Correct 9 ms 14848 KB Output is correct
98 Correct 11 ms 15104 KB Output is correct
99 Correct 9 ms 14848 KB Output is correct
100 Correct 10 ms 14848 KB Output is correct
101 Correct 10 ms 14848 KB Output is correct
102 Correct 9 ms 14848 KB Output is correct
103 Correct 9 ms 14848 KB Output is correct
104 Correct 9 ms 14848 KB Output is correct
105 Correct 9 ms 14848 KB Output is correct
106 Correct 9 ms 14848 KB Output is correct
107 Correct 9 ms 14848 KB Output is correct
108 Correct 9 ms 14912 KB Output is correct
109 Correct 10 ms 14336 KB Output is correct
110 Correct 9 ms 11520 KB Output is correct
111 Correct 9 ms 12032 KB Output is correct
112 Correct 8 ms 10240 KB Output is correct
113 Correct 8 ms 10752 KB Output is correct
114 Correct 9 ms 11008 KB Output is correct
115 Correct 9 ms 12544 KB Output is correct
116 Correct 8 ms 9984 KB Output is correct
117 Correct 9 ms 14592 KB Output is correct
118 Correct 9 ms 11264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 526 ms 23288 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -