Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Slices3D
- {
- static void Main()
- {
- int width, height, depth;
- string dimensionsStr = Console.ReadLine();
- string[] dimensions = dimensionsStr.Split(' ');
- width = int.Parse(dimensions[0]);
- height = int.Parse(dimensions[1]);
- depth = int.Parse(dimensions[2]);
- int [,,] cuboid = new int [width,height, depth];
- long totalSum = 0;
- for (int h = 0; h < height; h++)
- {
- string valuesStr = Console.ReadLine();
- string[] valuesByDimension = valuesStr.Split('|');
- for (int d = 0; d < depth; d++)
- {
- char[] delimiter = { ' ' };
- string[] values = valuesByDimension[d].Split(delimiter, StringSplitOptions.RemoveEmptyEntries);
- for (int w = 0; w < width; w++)
- {
- cuboid[w, h, d] = int.Parse(values[w]);
- totalSum += cuboid[w, h, d];
- }
- }
- }
- long currentSum = 0;
- int counter = 0;
- for (int w = 0; w < width-1; w++)
- {
- for (int h = 0; h < height; h++)
- {
- for (int d = 0; d < depth; d++)
- {
- currentSum += cuboid[w, h, d];
- }
- }
- if (currentSum + currentSum == totalSum)
- {
- counter++;
- }
- }
- currentSum = 0;
- for (int h = 0; h < height-1; h++)
- {
- for (int w = 0; w < width; w++)
- {
- for (int d = 0; d < depth; d++)
- {
- currentSum += cuboid[w, h, d];
- }
- }
- if (currentSum + currentSum == totalSum)
- {
- counter++;
- }
- }
- currentSum = 0;
- for (int d = 0; d < depth-1; d++)
- {
- for (int h = 0; h < height; h++)
- {
- for (int w = 0; w < width; w++)
- {
- currentSum += cuboid[w, h, d];
- }
- }
- if (currentSum + currentSum == totalSum)
- {
- counter++;
- }
- }
- Console.WriteLine(counter);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement