Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Text;
- public class Program
- {
- public static void Main()
- {
- int[] props = Console.ReadLine().Split().Select(int.Parse).ToArray();
- int rows = props[0];
- int cols = props[1];
- int[][]jagged = new int[rows][];
- int num = 0;
- for(int row=0; row<rows; row++)
- {
- jagged[row] = new int[cols];
- for(int col=0; col<cols; col++)
- {
- jagged[row][col] = num;
- num++;
- }
- }
- long ivoSum = 0L;
- while (true)
- {
- string command = Console.ReadLine();
- if (command == "Let the Force be with you")
- {
- break;
- }
- int[] ivoCoords = command.Split().Select(int.Parse).ToArray();
- int[] evilCoords = Console.ReadLine().Split().Select(int.Parse).ToArray();
- int ivoRow = ivoCoords[0];
- int ivoCol = ivoCoords[1];
- int evilRow = evilCoords[0];
- int evilCol = evilCoords[1];
- while (evilRow>=0 && evilCol>=0)
- {
- if(evilRow>=0 && evilCol>=0 && evilRow<rows && evilCol<cols)
- {
- jagged[evilRow][evilCol]=0;
- }
- evilRow--;
- evilCol--;
- }
- while (ivoRow>=0 && ivoCol<cols)
- {
- if(ivoRow>=0 && ivoCol>=0 && ivoRow<rows && ivoCol<cols)
- {
- ivoSum += jagged[ivoRow][ivoCol];
- }
- ivoRow--;
- ivoCol++;
- }
- }
- Console.WriteLine(ivoSum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement