Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static UInt64 HackerGrid2()
- {
- bool hacker = false;
- UInt64 sl = 0;
- string[] summaryRow;
- if (hacker)
- {
- summaryRow = Console.ReadLine().Split(' ');
- }
- else
- {
- summaryRow = new string[] { "4", "4", "3" };
- }
- UInt32 row = Convert.ToUInt32(summaryRow[0]);
- UInt32 col = Convert.ToUInt32(summaryRow[1]);
- Int32 k = Convert.ToInt32(summaryRow[2]);
- List<Tuple<UInt32, UInt32, UInt32>> tracks = new List<Tuple<UInt32, UInt32, UInt32>>(k);
- string[] rows;
- rows = new string[] { "2 2 3"
- , "3 1 4"
- , "4 4 4"
- };
- for (int j = 0; j < k; j++)
- {
- if (hacker)
- {
- summaryRow = Console.ReadLine().Split(' ');
- }
- else
- {
- summaryRow = rows[j].Split(' ');
- }
- UInt32 trow = Convert.ToUInt32(summaryRow[0]);
- UInt32 start = Convert.ToUInt32(summaryRow[1]);
- UInt32 end = Convert.ToUInt32(summaryRow[2]);
- tracks.Add(new Tuple<UInt32, UInt32, UInt32>(trow, start, end));
- }
- tracks.Sort();
- UInt32 lastRow = 0;
- UInt32 lastEnd = 0;
- sl = (UInt64)row * (UInt64)col;
- foreach (Tuple<UInt32, UInt32, UInt32> ts in tracks)
- {
- UInt32 trow = ts.Item1;
- UInt32 start = ts.Item2;
- UInt32 end = ts.Item3;
- if (trow > lastRow || start > lastEnd)
- {
- sl -= end - start + 1;
- lastEnd = end;
- }
- else if (end > lastEnd)
- {
- sl -= end - lastEnd;
- lastEnd = end;
- }
- lastRow = trow;
- }
- Console.WriteLine(sl);
- return sl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement