kotonoha_pcg@気ままに雑記

kotonoha_pcgが気分次第で様々書き置きます.dlang関係他:http://kotonoha-pcg.hatenadiary.com

CodeForces #298 Div2

Code Forces 初参加でした.

 一昨日のCFは一応参加
していたのですが,全くもってAすら解けていなかったので,リベンジ的な意味合いを込めて参加しました.

結論

 結論からいうと,0完太陽主義を貫いてしまいました.Aは30分を少し過ぎたところでSubmitしたけれど,“どうせミスしていないだろ”という慢心が仇となり,終了30分位前に撃墜されてました...

A Tavas and Nafas

 

  • 概要:数字s(0≦s≦99)が与えられるので,それに対応した単語を出力する.
  • 解法例:撃墜されたり終わったりした後に見たものとしては,配列を2つ用意して,それぞれ単語を格納して臨機応変に対応させていたみたいでした.コンテストの最中は,配列を使うという選択肢が全く思い浮かばなかったので,if文の乱用で100行書いてました(笑).今思うと本当に草が生えまくっています.

 以下,A問題のコードです.一応,終了後に再提出したものを載せます.

#include <bits/stdc++.h>
#include <cstdio>
using namespace std;

int main() {
	int s;
	cin>>s;
	if(s==0){cout<<"zero"<<endl;}
	if(s==1){cout<<"one"<<endl;}
	if(s==2){cout<<"two"<<endl;}
	if(s==3){cout<<"three"<<endl;}
	if(s==4){cout<<"four"<<endl;}
	if(s==5){cout<<"five"<<endl;}
	if(s==6){cout<<"six"<<endl;}
	if(s==7){cout<<"seven"<<endl;}
	if(s==8){cout<<"eight"<<endl;}
	if(s==9){cout<<"nine"<<endl;}
	if(s==10){cout<<"ten"<<endl;}
	if(s==11){cout<<"eleven"<<endl;}
	if(s==12){cout<<"twelve"<<endl;}
	if(s==13){cout<<"thirteen"<<endl;}
	if(s==14){cout<<"fourteen"<<endl;}
	if(s==15){cout<<"fifteen"<<endl;}
	if(s==16){cout<<"sixteen"<<endl;}
	if(s==17){cout<<"seventeen"<<endl;}
	if(s==18){cout<<"eighteen"<<endl;}
	if(s==19){cout<<"nineteen"<<endl;}
	if(s==20){cout<<"twenty"<<endl;}
	if(s==21){cout<<"twenty-one"<<endl;}
	if(s==22){cout<<"twenty-two"<<endl;}
	if(s==23){cout<<"twenty-three"<<endl;}
	if(s==24){cout<<"twenty-four"<<endl;}
	if(s==25){cout<<"twenty-five"<<endl;}
	if(s==26){cout<<"twenty-six"<<endl;}
	if(s==27){cout<<"twenty-seven"<<endl;}
	if(s==28){cout<<"twenty-eight"<<endl;}
	if(s==29){cout<<"twenty-nine"<<endl;}
	if(s==30){cout<<"thirty"<<endl;}
	if(s==31){cout<<"thirty-one"<<endl;}
	if(s==32){cout<<"thirty-two"<<endl;}
	if(s==33){cout<<"thirty-three"<<endl;}
	if(s==34){cout<<"thirty-four"<<endl;}
	if(s==35){cout<<"thirty-five"<<endl;}
	if(s==36){cout<<"thirty-six"<<endl;}
	if(s==37){cout<<"thirty-seven"<<endl;}
	if(s==38){cout<<"thirty-eight"<<endl;}
	if(s==39){cout<<"thirty-nine"<<endl;}
	if(s==40){cout<<"forty"<<endl;}
	if(s==41){cout<<"forty-one"<<endl;}
	if(s==42){cout<<"forty-two"<<endl;}
	if(s==43){cout<<"forty-three"<<endl;}
	if(s==44){cout<<"forty-four"<<endl;}
	if(s==45){cout<<"forty-five"<<endl;}
	if(s==46){cout<<"forty-six"<<endl;}
	if(s==47){cout<<"forty-seven"<<endl;}
	if(s==48){cout<<"forty-eight"<<endl;}
	if(s==49){cout<<"forty-nine"<<endl;}
	if(s==50){cout<<"fifty"<<endl;}
	if(s==51){cout<<"fifty-one"<<endl;}
	if(s==52){cout<<"fifty-two"<<endl;}
	if(s==53){cout<<"fifty-three"<<endl;}
	if(s==54){cout<<"fifty-four"<<endl;}
	if(s==55){cout<<"fifty-five"<<endl;}
	if(s==56){cout<<"fifty-six"<<endl;}
	if(s==57){cout<<"fifty-seven"<<endl;}
	if(s==58){cout<<"fifty-eight"<<endl;}
	if(s==59){cout<<"fifty-nine"<<endl;}
	if(s==60){cout<<"sixty"<<endl;}
	if(s==61){cout<<"sixty-one"<<endl;}
	if(s==62){cout<<"sixty-two"<<endl;}
	if(s==63){cout<<"sixty-three"<<endl;}
	if(s==64){cout<<"sixty-four"<<endl;}
	if(s==65){cout<<"sixty-five"<<endl;}
	if(s==66){cout<<"sixty-six"<<endl;}
	if(s==67){cout<<"sixty-seven"<<endl;}
	if(s==68){cout<<"sixty-eight"<<endl;}
	if(s==69){cout<<"sixty-nine"<<endl;}
	if(s==70){cout<<"seventy"<<endl;}
	if(s==71){cout<<"seventy-one"<<endl;}
	if(s==72){cout<<"seventy-two"<<endl;}
	if(s==73){cout<<"seventy-three"<<endl;}
	if(s==74){cout<<"seventy-four"<<endl;}
	if(s==75){cout<<"seventy-five"<<endl;}
	if(s==76){cout<<"seventy-six"<<endl;}
	if(s==77){cout<<"seventy-seven"<<endl;}
	if(s==78){cout<<"seventy-eight"<<endl;}
	if(s==79){cout<<"seventy-nine"<<endl;}
	if(s==80){cout<<"eighty"<<endl;}
	if(s==81){cout<<"eighty-one"<<endl;}
	if(s==82){cout<<"eighty-two"<<endl;}
	if(s==83){cout<<"eighty-three"<<endl;}
	if(s==84){cout<<"eighty-four"<<endl;}
	if(s==85){cout<<"eighty-five"<<endl;}
	if(s==86){cout<<"eighty-six"<<endl;}
	if(s==87){cout<<"eighty-seven"<<endl;}
	if(s==88){cout<<"eighty-eight"<<endl;}
	if(s==89){cout<<"eighty-nine"<<endl;}
	if(s==90){cout<<"ninety"<<endl;}
	if(s==91){cout<<"ninety-one"<<endl;}
	if(s==92){cout<<"ninety-two"<<endl;}
	if(s==93){cout<<"ninety-three"<<endl;}
	if(s==94){cout<<"ninety-four"<<endl;}
	if(s==95){cout<<"ninety-five"<<endl;}
	if(s==96){cout<<"ninety-six"<<endl;}
	if(s==97){cout<<"ninety-seven"<<endl;}
	if(s==98){cout<<"ninety-eight"<<endl;}
	if(s==99){cout<<"ninety-nine"<<endl;}
	
	
	return 0;
}

 自分でも「酷い」,の一言しか浮かばないのがなんとも..(決して行数稼ぎではないです,はい).

撃墜箇所

 撃墜されたのは,大体26行目の

if(s==18){cout<<"eighteen"<<endl;}

の部分で,これを何を思ったのか(確実に原因は(if文の)コピペと慢心なんですがw),"eighteen"を"eight「t」een"としていたのが敗因でした.今後の対策があるとすれば,しっかりとスペルミスが無いように正確に,且つ素早く確認するしか無いと考えています.

Bは,結局考えたものの解いていません.一応,与えられた数値の中に"4","7",または4と7双方「のみ」が含まれている場合にのみnまで値の数をカウントして表示するのですが,4だけまたは7だけは簡単実装として,それ以降の数値のカウント回数が殆ど実装方法が分からずに詰まってしまいました.また家に帰ったら他の解答例も見て,理屈と実装法を確認したいと思います.

総合的に感想

 CFに初めて参加して初めて撃墜を受けた訳でしたが,良い経験になったんじゃないかと思いました.また,流石にこのままの地力では金曜日のSRMも無理なのでは,ということで,もっと1日に1問はしっかりと解こう,と奮い立たせてもくれました.