2009-01-06
SRM380 Div1 Easy: LameKnight
SRM432前の準備運動(その2)
SRM開始まであと13分・・・
Test Caseは全部通ったのでsubmitしたけどSystem Test落ち
class LameKnight {
public:
int maxCells(int height, int width) {
if(height==1||width==1) return 1;
if(width==5) return 4;
if(height==2) return 1+(width-1)/2;
if(width<5) return width;
if(height>3) return width-2;
return width-3;
}
};
これは適当すぎると思うので、あとで見直そう。
→見直した。ちゃんとノートに書いて場合分けしたら簡単だった件
class LameKnight {
public:
int maxCells(int height, int width) {
if(height==1 || width==1) return 1;
if(height==2) return min(1+(width-1)/2, 4);
if(height>=3 && width<7) return min(width,4);
return width-2;
}
};
コメント
トラックバック - https://topcoder-g-hatena-ne-jp.jag-icpc.org/n4_t/20090106