Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.00 KB | None | 0 0
  1. StreamReader sr = new StreamReader("input.txt");
  2.             string line = sr.ReadLine();
  3.             Int64 houses = 1;
  4.             Int64 max = 10000;
  5.             int[,] hor= new int[max, max];
  6.             for (Int64 l = 0; l < max; l++)
  7.             { for (Int64 j = 0; j < max; j++)
  8.                     hor[l, j] = 0;
  9.             }
  10.             Int64 i = 0;
  11.             Int64 k = 0;
  12.             for (int j =1;j<=line.Length-1;j++)
  13.             {
  14.                 if (line[j]=='^')
  15.                 {
  16.                     if (k==max-1)
  17.                     {
  18.                         k = 0;
  19.                         if (hor[i, k] == 0)
  20.                         {
  21.                             hor[i, k]++;
  22.                             houses++;
  23.                         }
  24.                     }
  25.                     else
  26.                     {
  27.                         k++;
  28.                         if (hor[i, k] == 0)
  29.                         {
  30.                             hor[i, k]++;
  31.                             houses++;
  32.                         }
  33.                     }
  34.                 }
  35.                 if (line[j] == 'v')
  36.                 {
  37.                     if (k == 0)
  38.                     {
  39.                         k = max-1;
  40.                         if (hor[i, k] == 0)
  41.                         {
  42.                             hor[i, k]++;
  43.                             houses++;
  44.                         }
  45.                     }
  46.                     else
  47.                     {
  48.                         k--;
  49.                         if (hor[i, k] == 0)
  50.                         {
  51.                             hor[i, k]++;
  52.                             houses++;
  53.                         }
  54.                     }
  55.                 }
  56.                 if (line[j] == '>')
  57.                 {
  58.                     if (i == max-1)
  59.                     {
  60.                         i = 0;
  61.                         if (hor[i, k] == 0)
  62.                         {
  63.                             hor[i, k]++;
  64.                             houses++;
  65.                         }
  66.                     }
  67.                     else
  68.                     {
  69.                         i++;
  70.                         if (hor[i, k] == 0)
  71.                         {
  72.                             hor[i, k]++;
  73.                             houses++;
  74.                         }
  75.                     }
  76.                 }
  77.                 if (line[j] == '<')
  78.                 {
  79.                     if (i == 0)
  80.                     {
  81.                         i = max-1;
  82.                         if (hor[i, k] == 0)
  83.                         {
  84.                             hor[i, k]++;
  85.                             houses++;
  86.                         }
  87.                     }
  88.                     else
  89.                     {
  90.                         i--;
  91.                         if (hor[i, k] == 0)
  92.                         {
  93.                             hor[i, k]++;
  94.                             houses++;
  95.                         }
  96.                     }
  97.                 }
  98.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement