torus711 のアレ

主に競技プログラミングの問題について書きます.PC 以外だと数式が表示されないかもしれないです

TopCoder SRM 571, Division 2, Level 1 : FoxAndGame

概要

きつねさんがゲームをしている。
このゲームでは、各ステージに於いて 0 〜 3 つの星を獲得することができる。
あるステージについて、その結果を、"---", "o--", "oo-", "ooo" の文字列で表すこととする。
きつねさんがゲームをプレイした結果が与えれるので、獲得した星の合計数を求めよ。

解法

o の数を数えるだけです。

コード

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define ALL( c ) (c).begin(), (c).end()

class FoxAndGame
{
public:
	int countStars( vector <string> result )
	{
		int res = 0;
		REP( i, 0, result.size() )
		{
			res += count( ALL( result[i] ), 'o' );
		}
		return res;
	}
};