class CyclopeptideSequencing { static int GetMass(List<int> spectrum) { int i; int mass = 0; for (i = 0; i < spectrum.Count; i++) { mass += spectrum[i]; } return mass; } static bool NextPermutation(int[] numList) { int largestIndex = -1; for (int i = numList.Length - 2; i >= 0; i--) { if (numList[i] < numList[i + 1]) { largestIndex = i; break; } } if (largestIndex < 0) return false; int largestIndex2 = -1; for (int i = numList.Length - 1; i >= 0; i--) { if (numList[largestIndex] < numList[i]) { largestIndex2 = i; break; } } int tmp = numList[largestIndex]; numList[largestIndex] = numList[largestIndex2]; numList[largestIndex2] = tmp; for (int i = largestIndex + 1, j = numList.Length - 1; i < j; i++, j--) { tmp = numList[i]; numList[i] = numList[j]; numList[j] = tmp; } return true; } static int GetScore(List<int> spectrum1, List<int> spectrum2, int n2) { int i, j, curr, score = 0; /* first find the theoretical spectrum of the peptide */ List<int> theospectrum = new List<int>(); List<int> list1 = spectrum1.ToList(); List<int> list2 = spectrum2.ToList(); string go = ""; theospectrum.Add(0); curr = 1; /* obtain linear permutations of length 1 */ for (i = 0; i < n2; i++) { theospectrum.Add(spectrum2[i]); } if (GetMass(spectrum2) == spectrum1[spectrum1.Count - 1]) { for (i = 0; i < n2; i++) { list2.Add(spectrum2[i]); } curr = 1; while (curr < (n2 - 1)) { /* get subpeptides of length curr + 1 */ for (i = 0; i <= n2 - 1; i++) { int added = 0; for (j = i; j < i + curr + 1; j++) { added += list2[j]; } theospectrum.Add(added); } curr++; } int added2 = 0; for (i = 0; i < n2; i++) { added2 += spectrum2[i]; } theospectrum.Add(added2); } else { curr = 1; while (curr < (n2 - 1)) { /* get subpeptides of length curr + 1 */ for (i = 0; i < n2 - curr; i++) { int added = 0; for (j = i; j < i + curr + 1; j++) { added += spectrum2[j]; } theospectrum.Add(added); } curr++; } int added2 = 0; for (i = 0; i < n2; i++) { added2 += spectrum2[i]; } theospectrum.Add(added2); } for (i = 0; i < theospectrum.Count; i++) { if (list1.Contains(theospectrum[i])) { score++; list1.Remove(theospectrum[i]); } } return score; } static void Main(string[] args) { string n_str = Console.ReadLine(); int n = Convert.ToInt16(n_str); int i, j, k, leaderlength = 0; string currConcat = Console.ReadLine(); string input = ""; string output = ""; int[] integerMassTable = new int[] { 57, 71, 87, 97, 99, 101, 103, 113, 114, 115, 128, 129, 131, 137, 147, 156, 163, 186 }; List<int> integerMassList = integerMassTable.ToList(); List<int> integersUsed = new List<int>(); List<int> spectrumList; List<List<int>> leaderboard = new List<List<int>>(); List<int> leaderpeptide; int curr = 0; int prevmax = -1; while (currConcat != null) { input += currConcat; currConcat = Console.ReadLine(); } string[] spectrum_str = input.Split(); int[] spectrum = new int[spectrum_str.Length]; for (i = 0; i < spectrum_str.Length; i++) { spectrum[i] = Convert.ToInt16(spectrum_str[i]); } spectrumList = spectrum.ToList(); /* create initial peptides */ leaderboard.Add(new List<int>()); leaderboard[0].Add(0); leaderpeptide = leaderboard[0]; leaderlength = 1; for (i = 0; i < integerMassList.Count; i++) { if (spectrumList.Contains(integerMassList[i])) { if (!integersUsed.Contains(integerMassList[i])) { integersUsed.Add(integerMassList[i]); leaderboard.Add(new List<int>()); leaderboard[leaderlength].Add(integerMassList[i]); leaderlength++; } } } /* LeaderboardCyclopeptideSequencing */ while (leaderlength != 0) { /* branching step */ int previousLength = leaderlength; List<List<int>> previousLeaderboard = leaderboard.ToList(); leaderboard.Clear(); leaderlength = 0; for (i = 1; i < previousLength; i++) { for (j = 0; j < integerMassTable.Length; j++) { List<int> list = previousLeaderboard[i].ToList(); list.Add(integerMassTable[j]); leaderboard.Add(list); leaderlength++; } } /* matching step */ List<int> indexesToRemove = new List<int>(); List<int> indexesToKeep = new List<int>(); for (i = 0; i < leaderlength; i++) { if (GetMass(leaderboard[i]) == spectrum.Last()) { if (GetScore(spectrumList, leaderboard[i], leaderboard[i].Count) >= GetScore(spectrumList, leaderpeptide, leaderpeptide.Count)) { leaderpeptide = leaderboard[i].ToList(); leaderboard.RemoveAt(i); leaderlength--; } } else if (GetMass(leaderboard[i]) > spectrum.Last()) { /* remove leaderboard[i] */ indexesToRemove.Add(i); } } List<List<int>> newLeaderboard = leaderboard.ToList(); leaderboard.Clear(); for (i = 0; i < leaderlength; i++) { if (!indexesToRemove.Contains(i)) { indexesToKeep.Add(i); } } indexesToKeep.Sort(); for (i = 0; i < indexesToKeep.Count; i++) { leaderboard.Add(newLeaderboard[indexesToKeep[i]].ToList()); } leaderlength = leaderboard.Count; /* bounding step */ int[] allScores = new int[leaderlength]; indexesToKeep.Clear(); List<int> highestScores = new List<int>(); for (i = 0; i < leaderlength; i++) { int score = GetScore(spectrumList, leaderboard[i], leaderboard[i].Count); allScores[i] = score; highestScores.Add(score); } highestScores.Sort(); while (highestScores.Count > n) { highestScores.RemoveAt(0); } i = 0; previousLeaderboard = leaderboard.ToList(); leaderboard.Clear(); while (highestScores.Count > 0) { if (i == leaderlength) { i = 0; } if (allScores[i] == highestScores[0]) { leaderboard.Add(previousLeaderboard[i].ToList()); highestScores.RemoveAt(0); } i++; } leaderlength = leaderboard.Count; if (curr == 20) { break; } curr++; } for (i = 0; i < leaderpeptide.Count; i++) { output += leaderpeptide[i].ToString(); if (i != leaderpeptide.Count - 1) { output += "-"; } } Console.WriteLine(output); } }
Standard input is empty
Main.java:3: error: cannot find symbol static int GetMass(List<int> spectrum) ^ symbol: class List location: class CyclopeptideSequencing Main.java:3: error: unexpected type static int GetMass(List<int> spectrum) ^ required: reference found: int Main.java:14: error: cannot find symbol static bool NextPermutation(int[] numList) ^ symbol: class bool location: class CyclopeptideSequencing Main.java:52: error: cannot find symbol static int GetScore(List<int> spectrum1, List<int> spectrum2, int n2) ^ symbol: class List location: class CyclopeptideSequencing Main.java:52: error: unexpected type static int GetScore(List<int> spectrum1, List<int> spectrum2, int n2) ^ required: reference found: int Main.java:52: error: cannot find symbol static int GetScore(List<int> spectrum1, List<int> spectrum2, int n2) ^ symbol: class List location: class CyclopeptideSequencing Main.java:52: error: unexpected type static int GetScore(List<int> spectrum1, List<int> spectrum2, int n2) ^ required: reference found: int Main.java:136: error: cannot find symbol static void Main(string[] args) ^ symbol: class string location: class CyclopeptideSequencing Main.java:17: error: cannot find symbol for (int i = numList.Length - 2; i >= 0; i--) ^ symbol: variable Length location: variable numList of type int[] Main.java:29: error: cannot find symbol for (int i = numList.Length - 1; i >= 0; i--) ^ symbol: variable Length location: variable numList of type int[] Main.java:42: error: cannot find symbol for (int i = largestIndex + 1, j = numList.Length - 1; i < j; i++, j--) ^ symbol: variable Length location: variable numList of type int[] Main.java:57: error: cannot find symbol List<int> theospectrum = new List<int>(); ^ symbol: class List location: class CyclopeptideSequencing Main.java:57: error: unexpected type List<int> theospectrum = new List<int>(); ^ required: reference found: int Main.java:57: error: cannot find symbol List<int> theospectrum = new List<int>(); ^ symbol: class List location: class CyclopeptideSequencing Main.java:57: error: unexpected type List<int> theospectrum = new List<int>(); ^ required: reference found: int Main.java:58: error: cannot find symbol List<int> list1 = spectrum1.ToList(); ^ symbol: class List location: class CyclopeptideSequencing Main.java:58: error: unexpected type List<int> list1 = spectrum1.ToList(); ^ required: reference found: int Main.java:59: error: cannot find symbol List<int> list2 = spectrum2.ToList(); ^ symbol: class List location: class CyclopeptideSequencing Main.java:59: error: unexpected type List<int> list2 = spectrum2.ToList(); ^ required: reference found: int Main.java:60: error: cannot find symbol string go = ""; ^ symbol: class string location: class CyclopeptideSequencing Main.java:138: error: cannot find symbol string n_str = Console.ReadLine(); ^ symbol: class string location: class CyclopeptideSequencing Main.java:138: error: cannot find symbol string n_str = Console.ReadLine(); ^ symbol: variable Console location: class CyclopeptideSequencing Main.java:139: error: cannot find symbol int n = Convert.ToInt16(n_str); ^ symbol: variable Convert location: class CyclopeptideSequencing Main.java:141: error: cannot find symbol string currConcat = Console.ReadLine(); ^ symbol: class string location: class CyclopeptideSequencing Main.java:141: error: cannot find symbol string currConcat = Console.ReadLine(); ^ symbol: variable Console location: class CyclopeptideSequencing Main.java:142: error: cannot find symbol string input = ""; ^ symbol: class string location: class CyclopeptideSequencing Main.java:143: error: cannot find symbol string output = ""; ^ symbol: class string location: class CyclopeptideSequencing Main.java:145: error: cannot find symbol List<int> integerMassList = integerMassTable.ToList(); ^ symbol: class List location: class CyclopeptideSequencing Main.java:145: error: unexpected type List<int> integerMassList = integerMassTable.ToList(); ^ required: reference found: int Main.java:145: error: cannot find symbol List<int> integerMassList = integerMassTable.ToList(); ^ symbol: method ToList() location: variable integerMassTable of type int[] Main.java:146: error: cannot find symbol List<int> integersUsed = new List<int>(); ^ symbol: class List location: class CyclopeptideSequencing Main.java:146: error: unexpected type List<int> integersUsed = new List<int>(); ^ required: reference found: int Main.java:146: error: cannot find symbol List<int> integersUsed = new List<int>(); ^ symbol: class List location: class CyclopeptideSequencing Main.java:146: error: unexpected type List<int> integersUsed = new List<int>(); ^ required: reference found: int Main.java:147: error: cannot find symbol List<int> spectrumList; ^ symbol: class List location: class CyclopeptideSequencing Main.java:147: error: unexpected type List<int> spectrumList; ^ required: reference found: int Main.java:148: error: cannot find symbol List<List<int>> leaderboard = new List<List<int>>(); ^ symbol: class List location: class CyclopeptideSequencing Main.java:148: error: cannot find symbol List<List<int>> leaderboard = new List<List<int>>(); ^ symbol: class List location: class CyclopeptideSequencing Main.java:148: error: unexpected type List<List<int>> leaderboard = new List<List<int>>(); ^ required: reference found: int Main.java:148: error: cannot find symbol List<List<int>> leaderboard = new List<List<int>>(); ^ symbol: class List location: class CyclopeptideSequencing Main.java:148: error: cannot find symbol List<List<int>> leaderboard = new List<List<int>>(); ^ symbol: class List location: class CyclopeptideSequencing Main.java:148: error: unexpected type List<List<int>> leaderboard = new List<List<int>>(); ^ required: reference found: int Main.java:149: error: cannot find symbol List<int> leaderpeptide; ^ symbol: class List location: class CyclopeptideSequencing Main.java:149: error: unexpected type List<int> leaderpeptide; ^ required: reference found: int Main.java:156: error: cannot find symbol currConcat = Console.ReadLine(); ^ symbol: variable Console location: class CyclopeptideSequencing Main.java:159: error: cannot find symbol string[] spectrum_str = input.Split(); ^ symbol: class string location: class CyclopeptideSequencing Main.java:163: error: cannot find symbol spectrum[i] = Convert.ToInt16(spectrum_str[i]); ^ symbol: variable Convert location: class CyclopeptideSequencing Main.java:165: error: cannot find symbol spectrumList = spectrum.ToList(); ^ symbol: method ToList() location: variable spectrum of type int[] Main.java:168: error: cannot find symbol leaderboard.Add(new List<int>()); ^ symbol: class List location: class CyclopeptideSequencing Main.java:168: error: unexpected type leaderboard.Add(new List<int>()); ^ required: reference found: int Main.java:180: error: cannot find symbol leaderboard.Add(new List<int>()); ^ symbol: class List location: class CyclopeptideSequencing Main.java:180: error: unexpected type leaderboard.Add(new List<int>()); ^ required: reference found: int Main.java:193: error: cannot find symbol List<List<int>> previousLeaderboard = leaderboard.ToList(); ^ symbol: class List location: class CyclopeptideSequencing Main.java:193: error: cannot find symbol List<List<int>> previousLeaderboard = leaderboard.ToList(); ^ symbol: class List location: class CyclopeptideSequencing Main.java:193: error: unexpected type List<List<int>> previousLeaderboard = leaderboard.ToList(); ^ required: reference found: int Main.java:198: error: cannot find symbol for (j = 0; j < integerMassTable.Length; j++) ^ symbol: variable Length location: variable integerMassTable of type int[] Main.java:200: error: cannot find symbol List<int> list = previousLeaderboard[i].ToList(); ^ symbol: class List location: class CyclopeptideSequencing Main.java:200: error: unexpected type List<int> list = previousLeaderboard[i].ToList(); ^ required: reference found: int Main.java:208: error: cannot find symbol List<int> indexesToRemove = new List<int>(); ^ symbol: class List location: class CyclopeptideSequencing Main.java:208: error: unexpected type List<int> indexesToRemove = new List<int>(); ^ required: reference found: int Main.java:208: error: cannot find symbol List<int> indexesToRemove = new List<int>(); ^ symbol: class List location: class CyclopeptideSequencing Main.java:208: error: unexpected type List<int> indexesToRemove = new List<int>(); ^ required: reference found: int Main.java:209: error: cannot find symbol List<int> indexesToKeep = new List<int>(); ^ symbol: class List location: class CyclopeptideSequencing Main.java:209: error: unexpected type List<int> indexesToKeep = new List<int>(); ^ required: reference found: int Main.java:209: error: cannot find symbol List<int> indexesToKeep = new List<int>(); ^ symbol: class List location: class CyclopeptideSequencing Main.java:209: error: unexpected type List<int> indexesToKeep = new List<int>(); ^ required: reference found: int Main.java:212: error: cannot find symbol if (GetMass(leaderboard[i]) == spectrum.Last()) ^ symbol: method Last() location: variable spectrum of type int[] Main.java:221: error: cannot find symbol else if (GetMass(leaderboard[i]) > spectrum.Last()) ^ symbol: method Last() location: variable spectrum of type int[] Main.java:229: error: cannot find symbol List<List<int>> newLeaderboard = leaderboard.ToList(); ^ symbol: class List location: class CyclopeptideSequencing Main.java:229: error: cannot find symbol List<List<int>> newLeaderboard = leaderboard.ToList(); ^ symbol: class List location: class CyclopeptideSequencing Main.java:229: error: unexpected type List<List<int>> newLeaderboard = leaderboard.ToList(); ^ required: reference found: int Main.java:248: error: cannot find symbol List<int> highestScores = new List<int>(); ^ symbol: class List location: class CyclopeptideSequencing Main.java:248: error: unexpected type List<int> highestScores = new List<int>(); ^ required: reference found: int Main.java:248: error: cannot find symbol List<int> highestScores = new List<int>(); ^ symbol: class List location: class CyclopeptideSequencing Main.java:248: error: unexpected type List<int> highestScores = new List<int>(); ^ required: reference found: int Main.java:298: error: cannot find symbol Console.WriteLine(output); ^ symbol: variable Console location: class CyclopeptideSequencing Main.java:299: error: cannot find symbol Thread.Sleep(50000); ^ symbol: method Sleep(int) location: class Thread 77 errors
Standard output is empty