Div2も練習。
http://community.topcoder.com/stat?c=problem_statement&pm=12275
ヒストグラムを作る問題。
各数値の最大の高さを求め、その高さ+1から順に文字列を作っていけばよい。
class ValueHistogram { public: vector <string> build(vector <int> values) { int hist[10],ma; char str[11]; vector <string> res; ZERO(hist); ZERO(str); ma=0; int i,j; FOR(i,values.size()) ma=max(ma,++hist[values[i]]); for(j=ma+1;j>=1;j--) { FOR(i,10) str[i]=(hist[i]>=j)?'X':'.'; res.push_back(str); } return res; } };
まとめ
Div2 Easyとはいえこういう問題は珍しいイメージ。