Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Numerics;
- using System.Text;
- using System.Threading.Tasks;
- namespace CubicsRube
- {
- public class Program
- {
- public static void Main(string[] args)
- {
- var dimension = int.Parse(Console.ReadLine());
- var cube = CreateAnFill(dimension);
- var input = Console.ReadLine();
- while (input!=null&&!input.Equals("Analyze"))
- {
- var coordinates = input.Split(new[] {' ', '\t'}, StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse).ToArray();
- var xPos = coordinates[0];
- var yPos = coordinates[1];
- var zPos = coordinates[2];
- var partSize = coordinates[3];
- try
- {
- if (cube[xPos][yPos][zPos]==0)
- {
- cube[xPos][yPos][zPos] = partSize;
- }
- }
- catch (Exception)
- {
- //ignored
- }
- input = Console.ReadLine();
- }
- var count = 0;
- var sum = BigInteger.Zero;
- for (var i = 0; i < dimension; i++)
- {
- for (var j = 0; j < dimension; j++)
- {
- for (var k = 0; k < dimension; k++)
- {
- if (cube[i][j][k]==0)
- {
- count++;
- }
- else
- {
- sum += cube[i][j][k];
- }
- }
- }
- }
- Console.WriteLine(sum);
- Console.WriteLine(count);
- }
- private static int[][][] CreateAnFill(int dimension)
- {
- var matrix = new int[dimension][][];
- for (var i = 0; i < dimension; i++)
- {
- matrix[i]= new int[dimension][];
- for (var j = 0; j < dimension; j++)
- {
- matrix[i][j] = new int[dimension];
- for (var k = 0; k < dimension; k++)
- {
- matrix[i][j][k] = 0;
- }
- }
- }
- return matrix;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement