ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1119. Metro

Please give me test case 10. My program passes all the tests I found here.
Posted by Alex 14 Mar 2017 12:32
What do i wrong?

using System;
using System.Collections.Generic;

public class Program
{
/// <summary>
/// The main.
/// </summary>
public static void Main()
{

var size = new KeyValuePair<int, int>(int.Parse(sizeStr[0]), int.Parse(sizeStr[1]));

var coordDiag = new List<KeyValuePair<int, int>>(k);
for (int i = 0; i < k; i++)
{
}

int x = 1;
int y = 1;
var diagLength = Math.Sqrt(20000);
double result = 0;

while (true)
{
if (k == 0)
{
Console.WriteLine((size.Value + size.Key) * 100);
break;
}

if (k == 1)
{
Console.WriteLine(Math.Round((size.Value + size.Key - 2) * 100 + diagLength));
break;
}

if (coordDiag.Exists(_ => _.Key == x && _.Value == y))
{
result += diagLength;
x += 1;
y += 1;
}
else
{
if (coordDiag.Exists(_ => (_.Key == x && _.Value >= y) || (_.Key >= x && _.Value == y)))
{
int counterForX = 10000000;
int counterForY = 10000000;

for (int i = 0; i < coordDiag.Count; i++)
{
if ((coordDiag[i].Key == x && coordDiag[i].Value >= y) || (coordDiag[i].Key >= x && coordDiag[i].Value == y))
{
int stepX = coordDiag[i].Key - x;
int stepY = coordDiag[i].Value - y;

if ((stepY < stepX && stepY > 0) || stepX <= 0)
{
if (counterForY > stepY)
{
counterForY = stepY;
}
}
else if (stepX > 0)
{
if (counterForX > stepX)
{
counterForX = stepX;
}
}
}
}

if (counterForY < counterForX)
{
if (!coordDiag.Exists(_ => _.Key >= x + 1 && _.Value >= y + counterForY + 1)
&& coordDiag.Exists(_ => _.Key >= x + counterForX + 1 && _.Value >= y + 1))
{
x += 1;
result += 100;
}
else
{
y += 1;
result += 100;
}
}
else
{
if (!coordDiag.Exists(_ => _.Key >= x + counterForX + 1 && _.Value >= y + 1)
&& coordDiag.Exists(_ => _.Key >= x + 1 && _.Value >= y + counterForY + 1))
{
y += 1;
result += 100;
}
else
{
x += 1;
result += 100;
}
}
}
else if (x<size.Key+1 && y < size.Value+1)
{
result += 200;
x += 1;
y += 1;
}
else if(x == size.Key + 1 && y < size.Value + 1)
{
result += 100;
y += 1;
}
else if(x < size.Key + 1 && y == size.Value + 1)
{
result += 100;
x += 1;
}
}

if (x - 1 == size.Key && y - 1 == size.Value)
{
Console.WriteLine(Math.Round(result));
break;
}
}
}
}