2009-01-14
SRM371 Div1 Easy: SpiralRoute
こんなのに19分ぐらいかかってる。時間かかりすぎ><
最後の1〜2行(あるいは1〜2列)になるまで剥いたところで場合分け
class SpiralRoute {
public:
vector<int> thronePosition(int w, int l) {
int xmax=w-1, ymax=l-1, xmin=0, ymin=0;
vector<int> ans(2,0);
while(w>2 && l>2){
w-=2; l-=2; xmax--; ymax--; xmin++; ymin++;
}
if(w==l){
ans[0]=xmin;
ans[1]=(w==2)?ymax:ymin;
}else if(w>l){
ans[0]=(l==1)?xmax:xmin;
ans[1]=ymax;
}else{
ans[0]=xmin;
ans[1]=(w==1)?ymax:(ymin+1);
}
return ans;
}
};
コメント
トラックバック - https://topcoder-g-hatena-ne-jp.jag-icpc.org/n4_t/20090114