Advertisement
bullit3189

Jedi Galaxy

Jun 6th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Text;
  5.  
  6. public class Program
  7. {
  8. public static void Main()
  9. {
  10. int[] props = Console.ReadLine().Split().Select(int.Parse).ToArray();
  11.  
  12. int rows = props[0];
  13. int cols = props[1];
  14.  
  15. int[][]jagged = new int[rows][];
  16.  
  17. int num = 0;
  18.  
  19. for(int row=0; row<rows; row++)
  20. {
  21. jagged[row] = new int[cols];
  22.  
  23. for(int col=0; col<cols; col++)
  24. {
  25. jagged[row][col] = num;
  26. num++;
  27. }
  28. }
  29.  
  30. long ivoSum = 0L;
  31.  
  32. while (true)
  33. {
  34. string command = Console.ReadLine();
  35.  
  36. if (command == "Let the Force be with you")
  37. {
  38. break;
  39. }
  40.  
  41. int[] ivoCoords = command.Split().Select(int.Parse).ToArray();
  42. int[] evilCoords = Console.ReadLine().Split().Select(int.Parse).ToArray();
  43.  
  44. int ivoRow = ivoCoords[0];
  45. int ivoCol = ivoCoords[1];
  46.  
  47. int evilRow = evilCoords[0];
  48. int evilCol = evilCoords[1];
  49.  
  50. while (evilRow>=0 && evilCol>=0)
  51. {
  52. if(evilRow>=0 && evilCol>=0 && evilRow<rows && evilCol<cols)
  53. {
  54. jagged[evilRow][evilCol]=0;
  55. }
  56.  
  57. evilRow--;
  58. evilCol--;
  59. }
  60.  
  61. while (ivoRow>=0 && ivoCol<cols)
  62. {
  63. if(ivoRow>=0 && ivoCol>=0 && ivoRow<rows && ivoCol<cols)
  64. {
  65. ivoSum += jagged[ivoRow][ivoCol];
  66. }
  67.  
  68. ivoRow--;
  69. ivoCol++;
  70. }
  71. }
  72.  
  73. Console.WriteLine(ivoSum);
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement