using System; using System.IO; namespace Verifying_Distributed_Work { class Solver { int[][] inputs = new int[5][]; string[] outputs = new string[5]; public void Run() { Read(@"DATA2.txt"); for (int i = 0; i < inputs.Length; i++) { int[] scores = new int[inputs[i].Length]; int[] numbs = new int[inputs[i].Length]; for (int j = 0; j < numbs.Length; j++) numbs[j] = 0; int index = 0; for (int j = 0; j < inputs[i].Length; j++) { bool match = false; for (int k = 0; k < numbs.Length; k++) { if (inputs[i][j] == numbs[k]) { match = true; break; } } if (!match) { numbs[index] = inputs[i][j]; index++; } } for (int j = 0; j < inputs[i].Length; j++) { for (int k = 0; k < numbs.Length; k++) if (inputs[i][j] == numbs[k]) scores[k]++; } // See which one's higher int highNumb = 0, highIndex = 0; int secondNumb = 0, secondIndex = 0; for (int j = 0; j < scores.Length; j++) { if (scores[j] > highNumb) { highNumb = scores[j]; highIndex = j; } } for (int j = 0; j < scores.Length; j++) { if (j != highIndex && scores[j] >= secondNumb) { secondNumb = scores[j]; secondIndex = j; } } if (scores[highIndex] - scores[secondIndex] > Math.Round((double)(inputs[i].Length / 2 - 1))) outputs[i] = "verified"; else if (scores[highIndex] - scores[secondIndex] > 0) outputs[i] = "unverified"; else outputs[i] = "unknown"; } Write(@"OUT2.txt"); } void Read(string address) { using (StreamReader sr = new StreamReader(address)) { for (int i = 0; i < inputs.Length; i++) { int length = int.Parse(sr.ReadLine()); inputs[i] = new int[length]; for (int j = 0; j < length; j++) inputs[i][j] = int.Parse(sr.ReadLine()); } } } void Write(string address) { using (StreamWriter sw = new StreamWriter(address)) { for (int i = 0; i < outputs.Length; i++) sw.WriteLine(outputs[i]); } } } class Program { static void Main(string[] args) { Solver s = new Solver(); s.Run(); } } }