static void Main() { //var CatSays = "Mew!"; var notWin = "No concert!"; // Input var numberOfCats = Console.ReadLine() .Split() .Where(x => char.IsDigit(x[0])) .Select(byte.Parse) .ToArray()[0]; var numberOfSongs = Console.ReadLine() .Split() .Where(x => char.IsDigit(x[0])) .Select(byte.Parse) .ToArray()[0]; // Arrays to store input Cats = new int[numberOfCats][] .Select(x => x = new int[numberOfSongs]) .ToArray(); Songs = new int[numberOfSongs][] .Select(x => x = new int[numberOfCats]) .ToArray(); while (true) { // Cat X knows song Y // [0] cat, [1] song // Cat and Song count starts at ONE var curInputLine = Console.ReadLine() .Split() .Where(x => char.IsDigit(x[0])) .Select(byte.Parse) .Select(x => x - 1) .ToArray(); // Break if not enough arguments, // Mew! -> 0 arguments. if (curInputLine.Length < 2) { break; } // Cat X knows song Y Cats[curInputLine[0]][curInputLine[1]] = 1; // Song Y can be sung by Cat X Songs[curInputLine[1]][curInputLine[0]] = 1; } // Sort Songs by "popularity" with Cats. var myCompare = new CustomCopare(); Array.Sort(Cats, myCompare); // For each song the cat with least songs can sing. for (int curSong = 0; curSong < Cats[0].Length; curSong++) { // helper variables var curSongList = new int[numberOfCats]; var SongCounter = 0; // If the song is available check // against other cats. if (Cats[0][curSong] == 1) { // Check curSongList[0] = 1; checkOtherCats(curSong, SongCounter, curSongList); // Should not be necessary here. if (curSongList.Sum() == numberOfCats) { isConcert = true; } } } // Print Output if (isConcert) { Console.WriteLine(MinSongList); } else { Console.WriteLine(notWin); } }
static void Main() { //var CatSays = "Mew!"; var notWin = "No concert!"; // Input var numberOfCats = Console.ReadLine() .Split() .Where(x => char.IsDigit(x[0])) .Select(byte.Parse) .ToArray()[0]; var numberOfSongs = Console.ReadLine() .Split() .Where(x => char.IsDigit(x[0])) .Select(byte.Parse) .ToArray()[0]; // Arrays to store input Cats = new int[numberOfCats][] .Select(x => x = new int[numberOfSongs]) .ToArray(); Songs = new int[numberOfSongs][] .Select(x => x = new int[numberOfCats]) .ToArray(); while (true) { // Cat X knows song Y // [0] cat, [1] song // Cat and Song count starts at ONE var curInputLine = Console.ReadLine() .Split() .Where(x => char.IsDigit(x[0])) .Select(byte.Parse) .Select(x => x - 1) .ToArray(); // Break if not enough arguments, // Mew! -> 0 arguments. if (curInputLine.Length < 2) break; // Cat X knows song Y Cats[curInputLine[0]][curInputLine[1]] = 1; // Song Y can be sung by Cat X Songs[curInputLine[1]][curInputLine[0]] = 1; } // Sort Songs by "popularity" with Cats. var myCompare = new CustomCopare(); Array.Sort(Cats, myCompare); // For each song the cat with least songs can sing. for (int curSong = 0; curSong < Cats[0].Length; curSong++) { // helper variables var curSongList = new int[numberOfCats]; var SongCounter = 0; // If the song is available check // against other cats. if (Cats[0][curSong] == 1) { // Check curSongList[0] = 1; checkOtherCats(curSong, SongCounter, curSongList); // Should not be necessary here. if (curSongList.Sum() == numberOfCats) isConcert = true; } } // Print Output if (isConcert) Console.WriteLine(MinSongList); else Console.WriteLine(notWin); }