might solved feladat 4
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\",
|
||||
"WorkspaceRootPath": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"AbsoluteMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|c:\\users\\szabomarton\\desktop\\verseny\\fordulo_3\\program\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|solutionrelative:program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|e:\\h\u00E1zi\\13.oszt\u00E1ly\\neumann_verseny\\fordulo_3\\program\\virus.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"AbsoluteMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\virus.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|solutionrelative:virus.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
}
|
||||
],
|
||||
@@ -24,11 +24,11 @@
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
"Title": "Program.cs",
|
||||
"DocumentMoniker": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Program.cs",
|
||||
"DocumentMoniker": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\Program.cs",
|
||||
"RelativeDocumentMoniker": "Program.cs",
|
||||
"ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Program.cs",
|
||||
"ToolTip": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\Program.cs",
|
||||
"RelativeToolTip": "Program.cs",
|
||||
"ViewState": "AgIAABwAAAAAAAAAAAAIwCcAAAAiAAAAAAAAAA==",
|
||||
"ViewState": "AgIAAGgAAAAAAAAAAAAwwHsAAAAkAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-12T12:54:16.847Z",
|
||||
"EditorCaption": ""
|
||||
@@ -37,11 +37,11 @@
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 1,
|
||||
"Title": "Virus.cs",
|
||||
"DocumentMoniker": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Virus.cs",
|
||||
"DocumentMoniker": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\Virus.cs",
|
||||
"RelativeDocumentMoniker": "Virus.cs",
|
||||
"ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Virus.cs",
|
||||
"ToolTip": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\Virus.cs",
|
||||
"RelativeToolTip": "Virus.cs",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAADIAAAABAAAAAAAAAA==",
|
||||
"ViewState": "AgIAACMAAAAAAAAAAAAIwDAAAAAJAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-13T16:14:18.948Z",
|
||||
"EditorCaption": ""
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\",
|
||||
"WorkspaceRootPath": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"AbsoluteMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|c:\\users\\szabomarton\\desktop\\verseny\\fordulo_3\\program\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|solutionrelative:program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|e:\\h\u00E1zi\\13.oszt\u00E1ly\\neumann_verseny\\fordulo_3\\program\\virus.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"AbsoluteMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\virus.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|solutionrelative:virus.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
}
|
||||
],
|
||||
@@ -24,11 +24,11 @@
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
"Title": "Program.cs",
|
||||
"DocumentMoniker": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Program.cs",
|
||||
"DocumentMoniker": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\Program.cs",
|
||||
"RelativeDocumentMoniker": "Program.cs",
|
||||
"ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Program.cs",
|
||||
"ToolTip": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\Program.cs",
|
||||
"RelativeToolTip": "Program.cs",
|
||||
"ViewState": "AgIAAD8AAAAAAAAAAAAcwCcAAAAiAAAAAAAAAA==",
|
||||
"ViewState": "AgIAAGgAAAAAAAAAAAAwwHsAAAAkAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-12T12:54:16.847Z",
|
||||
"EditorCaption": ""
|
||||
@@ -37,11 +37,11 @@
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 1,
|
||||
"Title": "Virus.cs",
|
||||
"DocumentMoniker": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Virus.cs",
|
||||
"DocumentMoniker": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\Virus.cs",
|
||||
"RelativeDocumentMoniker": "Virus.cs",
|
||||
"ToolTip": "E:\\H\u00E1zi\\13.oszt\u00E1ly\\Neumann_Verseny\\fordulo_3\\Program\\Virus.cs",
|
||||
"ToolTip": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\Virus.cs",
|
||||
"RelativeToolTip": "Virus.cs",
|
||||
"ViewState": "AgIAAAMAAAAAAAAAAAAAADIAAAABAAAAAAAAAA==",
|
||||
"ViewState": "AgIAACMAAAAAAAAAAAAIwDAAAAAJAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-13T16:14:18.948Z",
|
||||
"EditorCaption": ""
|
||||
|
||||
@@ -11,8 +11,15 @@ namespace Program
|
||||
{
|
||||
public static Dictionary<int, List<int>> Contacts = new Dictionary<int, List<int>>();
|
||||
public static HashSet<int> InfectedPeople = new HashSet<int>();
|
||||
public static List<int> uniquePeople = new List<int>();
|
||||
public static HashSet<int> NewInfectedPeople = new HashSet<int>();
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Previous();
|
||||
}
|
||||
|
||||
public static void ListAllInfectionTreeVoid()
|
||||
{
|
||||
string path = $@"../../../forrasok/elek.txt";
|
||||
|
||||
@@ -24,6 +31,83 @@ namespace Program
|
||||
int infector = Convert.ToInt32(nums[0]);
|
||||
int infected = Convert.ToInt32(nums[1]);
|
||||
|
||||
if (!uniquePeople.Contains(infector))
|
||||
{
|
||||
uniquePeople.Add(infector);
|
||||
}
|
||||
|
||||
if (!uniquePeople.Contains(infected))
|
||||
{
|
||||
uniquePeople.Add(infected);
|
||||
}
|
||||
|
||||
if (Contacts.ContainsKey(infector))
|
||||
{
|
||||
Contacts[infector].Add(infected);
|
||||
}
|
||||
else
|
||||
{
|
||||
Contacts[infector] = new List<int> { infected };
|
||||
}
|
||||
}
|
||||
|
||||
InfectedPeople.Clear(); // Clear the set before starting the spread
|
||||
|
||||
int infectionTreeCount = 0;
|
||||
|
||||
// Spread the virus starting from each unique person if they are not already infected
|
||||
foreach (var person in uniquePeople)
|
||||
{
|
||||
if (!InfectedPeople.Contains(person))
|
||||
{
|
||||
infectionTreeCount++;
|
||||
Virus rootVirus = new Virus(person);
|
||||
InfectedPeople.Add(person); // Add the root virus to the infected set
|
||||
SpreadBFS(rootVirus, int.MaxValue); // Spread without depth limit
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine($"Infected people count: {InfectedPeople.Count}");
|
||||
Console.WriteLine($"Unique people count: {uniquePeople.Count}");
|
||||
Console.WriteLine($"Number of infection trees: {infectionTreeCount}");
|
||||
|
||||
// Verify if all unique people are infected
|
||||
bool allInfected = uniquePeople.All(person => InfectedPeople.Contains(person));
|
||||
Console.WriteLine($"All unique people infected: {allInfected}");
|
||||
|
||||
if (!allInfected)
|
||||
{
|
||||
var notInfected = uniquePeople.Where(person => !InfectedPeople.Contains(person)).ToList();
|
||||
Console.WriteLine("People not infected:");
|
||||
foreach (var person in notInfected)
|
||||
{
|
||||
Console.WriteLine(person);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Previous()
|
||||
{
|
||||
string path = $@"../../../forrasok/elek.txt";
|
||||
|
||||
var data = File.ReadAllLines(path);
|
||||
|
||||
foreach (var item in data)
|
||||
{
|
||||
string[] nums = item.Split(' ');
|
||||
int infector = Convert.ToInt32(nums[0]);
|
||||
int infected = Convert.ToInt32(nums[1]);
|
||||
|
||||
if (!uniquePeople.Contains(infector))
|
||||
{
|
||||
uniquePeople.Add(infector);
|
||||
}
|
||||
|
||||
if (!uniquePeople.Contains(infected))
|
||||
{
|
||||
uniquePeople.Add(infected);
|
||||
}
|
||||
|
||||
if (Contacts.ContainsKey(infector))
|
||||
{
|
||||
Contacts[infector].Add(infected);
|
||||
@@ -37,13 +121,43 @@ namespace Program
|
||||
Virus rootVirus = new Virus(2);
|
||||
InfectedPeople.Clear(); // Clear the set before starting the spread
|
||||
InfectedPeople.Add(2); // Add the root virus to the infected set
|
||||
SpreadBFS(rootVirus, 2);
|
||||
//Spread(rootVirus, 9);
|
||||
SpreadBFS(rootVirus, 5);
|
||||
//Spread(rootVirus, 15);
|
||||
|
||||
//rootVirus.PrintInfectionTreeWithDepth(2, 0, "->");
|
||||
rootVirus.PrintInfectionTree();
|
||||
|
||||
Console.WriteLine(InfectedPeople.Count);
|
||||
Console.WriteLine(rootVirus.CountInfectedInDepthRange(3, 10));
|
||||
|
||||
Console.WriteLine($"Infected people count: {InfectedPeople.Count}");
|
||||
Console.WriteLine($"Unique people count: {uniquePeople.Count}");
|
||||
|
||||
// Verify if all unique people are infected
|
||||
bool allInfected = uniquePeople.All(person => InfectedPeople.Contains(person));
|
||||
Console.WriteLine($"All unique people infected: {allInfected}");
|
||||
|
||||
if (!allInfected)
|
||||
{
|
||||
var notInfected = uniquePeople.Where(person => !InfectedPeople.Contains(person)).ToList();
|
||||
Console.WriteLine("People not infected:");
|
||||
foreach (var person in notInfected)
|
||||
{
|
||||
Console.WriteLine(person);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Virus rootVirus2 = new Virus(2);
|
||||
int count = 0;
|
||||
while (NewInfectedPeople.Count != uniquePeople.Count)
|
||||
{
|
||||
count++;
|
||||
SpreadBFS(rootVirus2, count);
|
||||
}
|
||||
|
||||
Console.WriteLine(count);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@@ -74,12 +188,6 @@ namespace Program
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the current virus should be healed
|
||||
if (currentDepth - currentVirus.InfectionTurn >= 8)
|
||||
{
|
||||
InfectedPeople.Remove(currentVirus.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,5 +47,22 @@ namespace Program
|
||||
infected.PrintInfectionTreeWithDepth(maxDepth, currentDepth + 1, indent + " ");
|
||||
}
|
||||
}
|
||||
|
||||
public int CountInfectedInDepthRange(int minDepth, int maxDepth, int currentDepth = 0)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
if (currentDepth >= minDepth && currentDepth <= maxDepth)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
|
||||
foreach (var infected in Infected)
|
||||
{
|
||||
count += infected.CountInfectedInDepthRange(minDepth, maxDepth, currentDepth + 1);
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -5,3 +5,10 @@ E:\Házi\13.osztály\Neumann_Verseny\fordulo_3\Program\obj\Debug\Program.csproj.
|
||||
E:\Házi\13.osztály\Neumann_Verseny\fordulo_3\Program\obj\Debug\Program.csproj.CoreCompileInputs.cache
|
||||
E:\Házi\13.osztály\Neumann_Verseny\fordulo_3\Program\obj\Debug\Program.exe
|
||||
E:\Házi\13.osztály\Neumann_Verseny\fordulo_3\Program\obj\Debug\Program.pdb
|
||||
C:\Users\szabomarton\Desktop\Verseny\fordulo_3\Program\bin\Debug\Program.exe.config
|
||||
C:\Users\szabomarton\Desktop\Verseny\fordulo_3\Program\bin\Debug\Program.exe
|
||||
C:\Users\szabomarton\Desktop\Verseny\fordulo_3\Program\bin\Debug\Program.pdb
|
||||
C:\Users\szabomarton\Desktop\Verseny\fordulo_3\Program\obj\Debug\Program.csproj.AssemblyReference.cache
|
||||
C:\Users\szabomarton\Desktop\Verseny\fordulo_3\Program\obj\Debug\Program.csproj.CoreCompileInputs.cache
|
||||
C:\Users\szabomarton\Desktop\Verseny\fordulo_3\Program\obj\Debug\Program.exe
|
||||
C:\Users\szabomarton\Desktop\Verseny\fordulo_3\Program\obj\Debug\Program.pdb
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
|
||||
Binary file not shown.
Reference in New Issue
Block a user