Az alábbi letöltési lehetőségek közül választhatsz: (
segítség)
Típus: text/plain
Tartalmaz szöveget
Karakterkódolás: utf-8
Méret: 4 KB
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace Lampak
{
class Program
{
static int n, m, h, k, c;
static int[,] l=new int[1000,2];
static bool[,] v = new bool[100, 100];
static int[,] t;
const int ExNo=10;
static void Main(string[] args)
{
Beolvas();
VMezok();
SotetMezok();
Kiir();
}
private static void SotetMezok()
{
if (!v[0,0]) t[0, 0] = 1;
for (int i = 1; i != n; i++)
{
int t1 = t[i - 1, 0];
if (!v[i, 0]) t1++;
t[i, 0] = t1;
}
for (int j = 1; j != m; j++)
{
int t2 = t[0, j - 1];
if (!v[0, j]) t2++;
t[0, j] = t2;
}
for (int i = 1; i != n; i++)
{
for (int j = 1; j != m; j++)
{
int t1 = t[i - 1, j];
int t2 = t[i, j - 1];
if (!v[i, j]) { t1++; t2++; }
if (t1 < t2) t[i, j] = t1; else t[i, j] = t2;
}
}
}
private static void VMezok()
{
for (int i = 0; i != k; i++)
{
for (int x = (l[i, 0] - h / 2); x <= (l[i, 0] + h / 2); x++)
{
for (int y = (l[i, 1] - h / 2); y <= (l[i, 1] + h / 2); y++)
{
if (x > 0 && y > 0 && x < (n + 1) && y < (m + 1))
{
if (v[x - 1, y - 1] != true)
{
c++;
v[x - 1, y - 1] = true;
}
}
}
}
}
}
private static void Beolvas()
{
using (TextReader tr = new StreamReader("lampak"+ExNo+".in"))
{
string line;
line = tr.ReadLine();
string[] valt = line.Split(' ');
n = Convert.ToInt32(valt[0]);
m = Convert.ToInt32(valt[1]);
k = Convert.ToInt32(valt[2]);
h = Convert.ToInt32(valt[3]);
for (int i = 0; i != k; i++)
{
line = tr.ReadLine();
valt = line.Split(' ');
l[i, 0] = Convert.ToInt32(valt[0]);
l[i, 1] = Convert.ToInt32(valt[1]);
}
}
t = new int[n, m];
}
private static void Kiir()
{
using (TextWriter tw = new StreamWriter("lampak"+ExNo+".out"))
{
tw.WriteLine(n * m - c);
tw.WriteLine(t[n - 1, m - 1]);
}
}
}
}