Skip to content
Snippets Groups Projects
Commit 99fef077 authored by Filip Štěpánek's avatar Filip Štěpánek
Browse files

Commmittee

parent a97b7d7b
No related branches found
No related tags found
No related merge requests found
Showing
with 179 additions and 59 deletions
......@@ -13,39 +13,9 @@
</component>
<component name="ChangeListManager">
<list default="true" id="fb35636b-3ea5-41ca-a93c-07e05201b816" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/../4IncomplAt/.idea/4IncomplAt.iml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../certificates/.idea/.gitignore" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../certificates/.idea/certificates.iml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../certificates/.idea/misc.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../certificates/.idea/modules.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../certificates/.idea/vcs.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../certificates/CMakeLists.txt" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../certificates/datapub/foo" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../certificates/datapub/pub00.in" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../certificates/datapub/pub01.in" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../certificates/datapub/pub01.out" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../certificates/datapub/pub02.in" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../certificates/datapub/pub02.out" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../certificates/datapub/pub03.in" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../certificates/datapub/pub03.out" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../certificates/datapub/pub04.in" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../certificates/datapub/pub04.out" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../certificates/datapub/pub05.in" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../certificates/datapub/pub05.out" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../certificates/datapub/pub06.in" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../certificates/datapub/pub06.out" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../certificates/datapub/pub07.in" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../certificates/datapub/pub07.out" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../certificates/datapub/pub08.in" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../certificates/datapub/pub08.out" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../certificates/datapub/pub09.in" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../certificates/datapub/pub09.out" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../certificates/datapub/pub10.in" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../certificates/datapub/pub10.out" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../certificates/datapub/test.in" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../certificates/datapub/vis.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../certificates/main.cpp" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../certificates/datapub/pub12.in" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../certificates/main.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/../certificates/main.cpp" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
......@@ -79,6 +49,7 @@
<property name="cf.first.check.clang-format" value="false" />
<property name="cidr.known.project.marker" value="true" />
<property name="cmake.loaded.for.project" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="nodejs_package_manager_path" value="npm" />
<property name="settings.editor.selected.configurable" value="CPPToolchains" />
</component>
......@@ -88,6 +59,11 @@
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
<configuration default="true" type="GradleAppRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" PASS_PARENT_ENVS_2="true">
<method v="2">
<option name="com.jetbrains.cidr.cpp.gradle.execution.GradleNativeBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
......@@ -104,6 +80,8 @@
<workItem from="1633771260257" duration="59000" />
<workItem from="1633895930723" duration="1819000" />
<workItem from="1633981575555" duration="298000" />
<workItem from="1642254152379" duration="20000" />
<workItem from="1642254180558" duration="760000" />
</task>
<servers />
</component>
......
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeWorkspace">
<contentRoot DIR="$PROJECT_DIR$" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/4IncomplAt.iml" filepath="$PROJECT_DIR$/.idea/4IncomplAt.iml" />
</modules>
</component>
</project>
\ No newline at end of file
8 7 3 3
0 1
0 2
0 3
0 4
1 5
1 6
2 7
\ No newline at end of file
10 9 3 3
0 1
0 7
1 2
1 9
1 4
2 8
3 4
4 5
5 6
\ No newline at end of file
10 9 3 3
0 2
1 2
1 4
2 7
3 4
3 8
4 5
5 6
6 9
\ No newline at end of file
......@@ -2,6 +2,8 @@
#include <list>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
int nodeCount, edgeCount, packNodesCount, packEdgesCount;
......@@ -36,19 +38,26 @@ int main() {
int counter = nodeCount;
while (counter > 2) {
std::set<Node *> rings;
for (auto &node: graph) {
//Find all leafs
auto leafs = GetLeafNodes(&node);
if (node.neighbors.size() == 1) {
rings.insert(node.neighbors[0]);
node.neighbors.clear();
}
}
//If you have at leat one leaf
if (leafs.empty())
continue;
std::map<Node *, std::vector<Node *>> merges;
for (auto node: rings)
merges.insert({node, GetLeafNodes(node)});
std::vector<std::vector<bool>> newCert;
for (auto merge: merges) {
auto node = merge.first;
auto leafs = merge.second;
std::vector<std::vector<bool>> newCert;
//Check if certificate of the current parent has at least two characters, if so, take it without surrounding 01
if (node.label.size() > 2)
newCert.emplace_back(node.label.begin() + 1, node.label.end() - 1);
if (node->label.size() > 2)
newCert.emplace_back(node->label.begin() + 1, node->label.end() - 1);
//Take the children labels
for (auto leaf: leafs) {
......@@ -59,40 +68,47 @@ int main() {
std::sort(newCert.begin(), newCert.end());
//Build the new label
node.label.clear();
node.label.push_back(false);
node->label.clear();
node->label.push_back(false);
for (auto certPart: newCert) {
node.label.insert(node.label.end(), certPart.begin(), certPart.end());
node->label.insert(node->label.end(), certPart.begin(), certPart.end());
}
node.label.push_back(true);
node->label.push_back(true);
counter -= leafs.size();
for (auto leaf: leafs) {
auto it = std::find(node->neighbors.begin(), node->neighbors.end(), leaf);
node->neighbors.erase(it);
}
}
}
if (counter <= 2) {
std::vector<std::vector<bool>> result;
for (auto &node: rings) {
result.push_back(node->label);
}
return 0;
}
std::sort(result.begin(), result.end());
int GetDegree(Node *node){
int deg = 0;
for (auto neighbor : node->neighbors) {
if (!neighbor->visited)
deg++;
for (auto arr: result)
for (auto bit: arr)
std::cout << bit;
std::cout << std::endl;
}
}
return deg;
return 0;
}
std::vector<Node *> GetLeafNodes(Node *node) {
std::vector<Node *> leafs;
if (node->visited)
return leafs;
for(auto neighbor : node->neighbors){
if (GetDegree(neighbor) < 2 && !neighbor->visited ){
for (auto neighbor: node->neighbors) {
if (neighbor->neighbors.size() < 2) {
leafs.push_back(neighbor);
neighbor->visited = true;
}
}
......
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/
<?xml version="1.0" encoding="UTF-8"?>
<module classpath="CMake" type="CPP_MODULE" version="4" />
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/committee.iml" filepath="$PROJECT_DIR$/.idea/committee.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>
\ No newline at end of file
cmake_minimum_required(VERSION 3.16)
project(committee)
set(CMAKE_CXX_STANDARD 14)
add_executable(committee main.cpp)
abcd 3 2 5
2
abcd
dcba
3
abc
abc
dcba
4
abcd
abc
abcd
aba
20
uvwxyz 2 2 4
2
uv
wxyz
2
vu
zwyx
0
klmnoprstu 2 1 111
1
tt
2
kk
ms
0
abcde 5 1 15
1
a
2
ba
bbb
3
caaa
cbbbb
cccccc
4
daaaaaa
dbbbbbbb
dcccccccc
dddddddddd
5
eaaaaaaaaaa
ebbbbbbbbbbb
ecccccccccccc
eddddddddddddd
eeeeeeeeeeeeeee
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment