Advertisement
Guest User

5. Penguin Airlines

a guest
Jun 2nd, 2016
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.58 KB | None | 0 0
  1. namespace _04.FourthTask
  2. {
  3.     using System;
  4.     using System.Collections.Generic;
  5.     using System.Linq;
  6.     using System.Text;
  7.     using System.Threading.Tasks;
  8.  
  9.     public class Program
  10.     {
  11.         public static void Main()
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.             StringBuilder strB = new StringBuilder();
  15.             Dictionary<int, HashSet<int>> dic = new Dictionary<int, HashSet<int>>();
  16.             for (int i = 0; i < n; i++)
  17.             {
  18.                 dic.Add(i, new HashSet<int>());
  19.                 string input = Console.ReadLine();
  20.                 if (input == "None")
  21.                 {
  22.                     dic[i].Add(-1);
  23.                 }
  24.                 else
  25.                 {
  26.                     int[] str = input.Split().Select(int.Parse).ToArray();
  27.                     foreach (int number in str)
  28.                     {
  29.                         dic[i].Add(number);
  30.                     }
  31.                 }
  32.             }
  33.  
  34.             string inputT = Console.ReadLine();
  35.             while (inputT != "Have a break")
  36.             {
  37.                 int[] inputToN = inputT.Split().Select(int.Parse).ToArray();
  38.                 if (dic[inputToN[0]].Contains(inputToN[1]))
  39.                 {
  40.                     strB.AppendLine("There is a direct flight.");
  41.                 }
  42.                 else
  43.                 {
  44.                     strB.AppendLine("No flights available.");
  45.                 }
  46.  
  47.                 inputT = Console.ReadLine();
  48.             }
  49.  
  50.             Console.WriteLine(strB.ToString());
  51.         }
  52.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement