TopCoder SRM 496をC#で練習

参加できてなかったので本番のつもりで練習。

Div2 Medium: ColoredStrokes

using System;

class ColoredStrokes
{
    public int getLeast(string[] picture)
    {
        int res = 0;
        int width = picture[0].Length;
        int height = picture.Length;
        for (int i = 0; i < height; i++)
        {
            bool onHStroke = false;
            for (int j = 0; j < width; j++)
            {
                if (picture[i][j] == 'R' || picture[i][j] == 'G')
                {
                    if (!onHStroke)
                    {
                        res++;
                        onHStroke = true;
                    }
                }
                else
                {
                    onHStroke = false;
                }
            }

        }
        for (int i = 0; i < width; i++)
        {
            bool onVStroke = false;
            for (int j = 0; j < height; j++)
            {
                if (picture[j][i] == 'B' || picture[j][i] == 'G')
                {
                    if (!onVStroke)
                    {
                        res++;
                        onVStroke = true;
                    }
                }
                else
                {
                    onVStroke = false;
                }
            }

        }
        return res;
    }
}

縦と横でそれぞれストローク数をカウントするだけ。
二重ループ一個で書けるかな・・・。
271.27ptでsubmitしてシステムテストもクリア。