public void Init(BaseMapData mapData)
    {
        _mapData   = (KrbMapData)mapData;
        _mapHelper = new RectGridMap(_mapData.DistanceStrategy); // Instantiate selectively from data

        _palette = new Dictionary <KrbTileType, KrbTile>();
        foreach (var entry in _mapData.Palette)
        {
            var castTile = (KrbTile)entry;
            _palette.Add(castTile.TileType, castTile);
        }
    }
Exemple #2
0
    static string Solve()
    {
        var n = int.Parse(Console.ReadLine());
        var s = Array.ConvertAll(new bool[n], _ => Console.ReadLine().ToCharArray());

        // WA
        var t        = NewArray2 <int>(n, n);
        var triplets = new RectGridMap <List <PB> >(n, n, () => new List <PB>());

        // Horizontal
        for (int i = 0; i < n; i++)
        {
            for (int j = 1; j < n - 1; j++)
            {
                if (s[i][j - 1] == X && s[i][j] == X && s[i][j + 1] == X)
                {
                    t[i][j - 1]++;
                    t[i][j]++;
                    t[i][j + 1]++;

                    var pb = new PB {
                        p = new Point(i, j)
                    };
                    triplets[i, j - 1].Add(pb);
                    triplets[i, j].Add(pb);
                    triplets[i, j + 1].Add(pb);
                }
            }
        }
        // Vertical
        for (int j = 0; j < n; j++)
        {
            for (int i = 1; i < n - 1; i++)
            {
                if (s[i - 1][j] == X && s[i][j] == X && s[i + 1][j] == X)
                {
                    t[i - 1][j]++;
                    t[i][j]++;
                    t[i + 1][j]++;

                    var pb = new PB {
                        p = new Point(i, j), vertical = true
                    };
                    triplets[i - 1, j].Add(pb);
                    triplets[i, j].Add(pb);
                    triplets[i + 1, j].Add(pb);
                }
            }
        }

        var q = PQ <Point> .CreateWithKey(p => t[p.i][p.j], true);

        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                if (t[i][j] > 0)
                {
                    q.Push(new Point(i, j));
                }
            }
        }

        while (q.Count > 0)
        {
            var(c, p) = q.Pop();
            if (t[p.i][p.j] != c)
            {
                continue;
            }

            s[p.i][p.j] = O;

            foreach (var pb in triplets[p])
            {
                if (pb.end)
                {
                    continue;
                }
                pb.end = true;

                var(i, j) = pb.p;
                if (!pb.vertical)
                {
                    t[i][j - 1]--;
                    t[i][j]--;
                    t[i][j + 1]--;

                    if (t[i][j - 1] > 0)
                    {
                        q.Push(new Point(i, j - 1));
                    }
                    if (t[i][j] > 0)
                    {
                        q.Push(new Point(i, j));
                    }
                    if (t[i][j + 1] > 0)
                    {
                        q.Push(new Point(i, j + 1));
                    }
                }
                else
                {
                    t[i - 1][j]--;
                    t[i][j]--;
                    t[i + 1][j]--;

                    if (t[i - 1][j] > 0)
                    {
                        q.Push(new Point(i - 1, j));
                    }
                    if (t[i][j] > 0)
                    {
                        q.Push(new Point(i, j));
                    }
                    if (t[i + 1][j] > 0)
                    {
                        q.Push(new Point(i + 1, j));
                    }
                }
            }
        }

        return(string.Join("\n", s.Select(cs => new string(cs))));
    }