답안 #420434

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
420434 2021-06-08T11:12:35 Z kostia244 항공 노선도 (JOI18_airline) C++17
0 / 100
703 ms 25092 KB
#include "Alicelib.h"
#include<bits/stdc++.h>
using namespace std;

void Alice(int n, int m, int A[], int B[] ){
	if(n < 3 || m == 0) {
		InitG(n, m);
		for(int i = 0; i < m; i++)
			MakeG(i, A[i], B[i]);
		return;
	}

	vector<int> label(3024);
	for(int z = 0, i = 0; i < 1000; i++) {
		while(z > 1 && !(z&(z-1))) z++;
		label[i] = z ? z : 1023;
		z++;
		if(i < 5) {
			//cout << i << " = " << label[i] << endl;
		}
	}

	vector<array<int, 2>> edges;
	vector<int> baka(n);
	for(int i = 0; i < m; i++) {
		baka[A[i]]++;
		baka[B[i]]++;
	}
	for(int i = 0; i < m; i++) edges.push_back({A[i], B[i]});
	for(int i = 0; i < n; i++) if(baka[i]) edges.push_back({n, i});
	edges.push_back({n+1, n});
	for(int bit = 0; bit < 10; bit++) {
		if(bit)
			edges.push_back({n+1+bit, n+2+bit});
		for(int i = 0; i < n; i++) if((label[i]>>bit)&1) {
			edges.push_back({n+2+bit, i});
		}
	}
	//for(auto [u, v] : edges) cout << u << " " << v << endl;
	InitG(n+12, edges.size());
	for(int i = 0; i < edges.size(); i++)
		MakeG(i, edges[i][0], edges[i][1]);
}

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

void Bob( int V, int U, int C[], int D[] ){
	if(V < 3 || U == 0) {
		InitMap(V, U);
		for(int i = 0; i < U; i++)
			MakeMap(C[i], D[i]);
		return;
	}
	
	vector<int> label(3024);
	for(int z = 0, i = 0; i < 1000; i++) {
		while(z > 1 && !(z&(z-1))) z++;
		label[z ? z : 1023] = i;
		z++;
	}

	vector<vector<int>> g(V);
	vector<int> real(V, -1);
	for(int i = 0; i < U; i++) {
		g[C[i]].push_back(D[i]);
		g[D[i]].push_back(C[i]);
	}
	int sun = 0;
	while(g[sun].size()!=1) sun++;
	sun = g[sun][0];
	for(auto i : g[sun]) if(g[i].size()>1)real[i] = 0;
	int start = -1, prev = -1;
	for(int i = 0; i < V; i++) if(!real[i]) {
		int popcnt = -1;
		for(int j : g[i]) if(real[j]  && j != sun) {
			//cout << i << " to " << j<< endl;
			if(popcnt == -1) popcnt = j;
			if(popcnt != j) popcnt = -2;
		}
		if(popcnt >= 0) {
			//cout << "uwu " << i << " " << popcnt << endl;
			start = popcnt;
			break;
		}
	}
	//cout << start << "hm\n" << endl;
	vector<int> bits {start};
	while(bits.size() < 10) {
		for(auto i : g[start]) if(real[i] && i != prev) {
			prev = start;
			start = i;
			break;
		}
		bits.push_back(start);
	}

	for(int i = 0; i < 10; i++) {
		for(int j : g[bits[i]]) if(real[j] != -1)
			real[j] += 1<<i;
	}

	//for(auto i : real) cout << i << " "; cout << endl;
	for(int &i : real) if(i != -1) i = label[i];
	//for(auto i : real) cout << i << " "; cout << endl;

	int ed = 0;
	for(int i = 0; i < U; i++)
		ed += real[C[i]] >= 0 && real[D[i]] >= 0;
	InitMap(V-12, ed );
	for(int i = 0; i < U; i++) {
		if(real[C[i]] >= 0 && real[D[i]] >= 0)
			MakeMap(real[C[i]], real[D[i]]);
	}
}

Compilation message

Alice.cpp: In function 'void Alice(int, int, int*, int*)':
Alice.cpp:41:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |  for(int i = 0; i < edges.size(); i++)
      |                 ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4588 KB Output is correct
2 Correct 3 ms 4588 KB Output is correct
3 Correct 3 ms 4588 KB Output is correct
4 Correct 3 ms 4580 KB Output is correct
5 Incorrect 3 ms 4516 KB Wrong Answer [12]
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4588 KB Output is correct
2 Correct 3 ms 4588 KB Output is correct
3 Correct 3 ms 4588 KB Output is correct
4 Correct 3 ms 4580 KB Output is correct
5 Incorrect 3 ms 4516 KB Wrong Answer [12]
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 703 ms 25092 KB Output is correct : V - N = 12
2 Correct 480 ms 21448 KB Output is correct : V - N = 12
3 Correct 247 ms 11760 KB Output is correct : V - N = 12
4 Incorrect 8 ms 5240 KB Wrong Answer [14]
5 Halted 0 ms 0 KB -