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.Text;
- using System.Threading.Tasks;
- namespace _3DLines
- {
- class Program
- {
- static int width;
- static int height;
- static int depth;
- static char[, ,] matrix;
- static char curChar;
- static int curd;
- static int curh;
- static int curw;
- static SortedDictionary<int,long> result = new SortedDictionary<int,long>();
- static void Main(string[] args)
- {
- ReadInput();
- AssignMatrix();
- CheckForLines();
- int max = 0;
- foreach (var item in result)
- {
- if (item.Key > max)
- {
- max = item.Key;
- }
- }
- if (result.Count == 0)
- {
- Console.WriteLine(-1);
- }
- else
- {
- Console.WriteLine(result.Keys.Last() + 1 + " " + result.Values.Last());
- }
- }
- static void CheckForLines()
- {
- for (int w = 0; w < width; w++)
- {
- for (int h = 0; h < height; h++)
- {
- for (int d = 0; d < depth; d++)
- {
- curChar = matrix[w, h, d];
- curd = d;
- curh = h;
- curw = w;
- HeightLinePlus();
- //HeightLineMinus();
- WidthLinePlus();
- // WidthLineMinus();
- DepthLinePlus();
- // DepthLineMinus();
- }
- }
- }
- }
- private static void HeightLinePlus()
- {
- int times = 0;
- int curheight = curh;
- int curdepth = curd;
- int curwidth = curw;
- while (curheight < height - 1)
- {
- curheight++;
- if (matrix[curwidth, curheight, curdepth] == curChar)
- {
- times++;
- }
- }
- if (result.ContainsKey(times))
- {
- result[times] += (long)1;
- }
- else if (times != 0)
- {
- result.Add(times, (long)1);
- }
- times = 0;
- curheight = curh;
- curdepth = curd;
- curwidth = curw;
- while (curheight < height - 1 && curdepth < depth - 1)
- {
- curheight++;
- curdepth++;
- if (matrix[curwidth, curheight, curdepth] == curChar)
- {
- times++;
- }
- }
- if (result.ContainsKey(times))
- {
- result[times] += (long)1;
- }
- else if (times != 0)
- {
- result.Add(times, (long)1);
- }
- times = 0;
- curheight = curh;
- curdepth = curd;
- curwidth = curw;
- while (curheight < height - 1 && curwidth < width - 1)
- {
- curheight++;
- curwidth++;
- if (matrix[curwidth, curheight, curdepth] == curChar)
- {
- times++;
- }
- }
- if (result.ContainsKey(times))
- {
- result[times] += (long)1;
- }
- else if (times != 0)
- {
- result.Add(times, (long)1);
- }
- //times = 0;
- //curheight = curh;
- //curdepth = curd;
- //curwidth = curw;
- //while (curheight < height - 1 && curwidth < width - 1 && curdepth < depth - 1)
- //{
- // curheight++;
- // curwidth++;
- // curdepth++;
- // if (matrix[curwidth, curheight, curdepth] == curChar)
- // {
- // times++;
- // }
- //}
- //if (result.ContainsKey(times))
- //{
- // result[times] += (long)1;
- //}
- //else if (times != 0)
- //{
- // result.Add(times, (long)1);
- //}
- }
- private static void DepthLinePlus()
- {
- int times = 0;
- int curheight = curh;
- int curdepth = curd;
- int curwidth = curw;
- while (curdepth < depth - 1)
- {
- curdepth++;
- if (matrix[curwidth, curheight, curdepth] == curChar)
- {
- times++;
- }
- }
- if (result.ContainsKey(times))
- {
- result[times] += (long)1;
- }
- else if (times != 0)
- {
- result.Add(times, (long)1);
- }
- times = 0;
- curheight = curh;
- curdepth = curd;
- curwidth = curw;
- while (curheight < height - 1 && curdepth < depth - 1)
- {
- curheight++;
- curdepth++;
- if (matrix[curwidth, curheight, curdepth] == curChar)
- {
- times++;
- }
- }
- if (result.ContainsKey(times))
- {
- result[times] += (long)1;
- }
- else if (times != 0)
- {
- result.Add(times, (long)1);
- }
- times = 0;
- curheight = curh;
- curdepth = curd;
- curwidth = curw;
- while (curdepth < depth - 1 && curwidth < width - 1)
- {
- curdepth++;
- curwidth++;
- if (matrix[curwidth, curheight, curdepth] == curChar)
- {
- times++;
- }
- }
- if (result.ContainsKey(times))
- {
- result[times] += (long)1;
- }
- else if (times != 0)
- {
- result.Add(times, (long)1);
- }
- //times = 0;
- //curheight = curh;
- //curdepth = curd;
- //curwidth = curw;
- //while (curheight < height - 1 && curwidth < width - 1 && curdepth < depth - 1)
- //{
- // curheight++;
- // curwidth++;
- // curdepth++;
- // if (matrix[curwidth, curheight, curdepth] == curChar)
- // {
- // times++;
- // }
- //}
- //if (result.ContainsKey(times))
- //{
- // result[times] += (long)1;
- //}
- //else if (times != 0)
- //{
- // result.Add(times, (long)1);
- //}
- }
- private static void WidthLinePlus()
- {
- int times = 0;
- int curheight = curh;
- int curdepth = curd;
- int curwidth = curw;
- while (curwidth < width - 1)
- {
- curwidth++;
- if (matrix[curwidth, curheight, curdepth] == curChar)
- {
- times++;
- }
- }
- if (result.ContainsKey(times))
- {
- result[times] += (long)1;
- }
- else if (times != 0)
- {
- result.Add(times, (long)1);
- }
- times = 0;
- curheight = curh;
- curdepth = curd;
- curwidth = curw;
- while (curwidth < width - 1 && curdepth < depth - 1)
- {
- curwidth++;
- curdepth++;
- if (matrix[curwidth, curheight, curdepth] == curChar)
- {
- times++;
- }
- }
- if (result.ContainsKey(times))
- {
- result[times] += (long)1;
- }
- else if (times != 0)
- {
- result.Add(times, (long)1);
- }
- times = 0;
- curheight = curh;
- curdepth = curd;
- curwidth = curw;
- while (curheight < height - 1 && curwidth < width - 1)
- {
- curheight++;
- curwidth++;
- if (matrix[curwidth, curheight, curdepth] == curChar)
- {
- times++;
- }
- }
- if (result.ContainsKey(times))
- {
- result[times] += (long)1;
- }
- else if (times != 0)
- {
- result.Add(times, (long)1);
- }
- //times = 0;
- //curheight = curh;
- //curdepth = curd;
- //curwidth = curw;
- //while (curheight < height - 1 && curwidth < width - 1 && curdepth < depth - 1)
- //{
- // curheight++;
- // curwidth++;
- // curdepth++;
- // if (matrix[curwidth, curheight, curdepth] == curChar)
- // {
- // times++;
- // }
- //}
- //if (result.ContainsKey(times))
- //{
- // result[times] += (long)1;
- //}
- //else if (times != 0)
- //{
- // result.Add(times, (long)1);
- //}
- }
- static void AssignMatrix()
- {
- for (int h = 0; h < height; h++)
- {
- string[] cubes = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- for (int d = 0; d < depth; d++)
- {
- for (int w = 0; w < width; w++)
- {
- matrix[w, h, d] = cubes[d][w];
- }
- }
- }
- }
- static void ReadInput()
- {
- string[] constraints = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- width = int.Parse(constraints[0]);
- height = int.Parse(constraints[1]);
- depth = int.Parse(constraints[2]);
- matrix = new char[width, height, depth];
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement