適当に非再帰で簡単に実装できます。
たとえば、左に潜るなら i <<= 1 のようなことをすればよいです。
auto x = e; // 今まで足した値。単位元で初期化while (i < n) {
i <<= 1;
auto tmp = op(x, a[i]);
if (p(tmp)) {
// 左の子を足しても大丈夫
x = tmp; // 足した結果で上書き
i += 1;
} else {
// 左の子を足すとだめ// 特に何もしなくていいね
}
}
return i - n;
Recall that to finish a problem, you need to correctly answer two data in a row, with the same program.
Correct answer, with a program different from the last one.
BAD NEWS: You can no longer finish this problem, because you would need to answer the next data correctly with the same program, yet there are no data left for this problem. Recall that to finish a problem, you need to correctly answer two data in a row, with the same program.
Correct answer, with a program different from the last one.
Proceed to the next data.
Recall that to finish a problem, you need to correctly answer two data in a row, with the same program.
Empty answer.
You either specified a wrong file name which does not exist, or an empty file. Enter a correct file name in the box.
Empty program.
You either specified a wrong file name which does not exist, or an empty file. Enter a correct file name in the box.
No answer file.
Enter a file name in the box.
Missing problem.
Select a problem in the list.
No program file.
Enter a file name in the box.
Wrong answer.
Try again.
Wrong answer.
Try again.
You need to correctly answer two more data. Recall that to finish a problem, you need to correctly answer two data in a row, with the same program.
Wrong answer.
BAD NEWS: You can no longer finish this problem, because you would need to answer two more data correctly, yet there is only one data left for this problem. Recall that to finish a problem, you need to correctly answer two data in a row, with the same program.
The contest is over.
You can no longer send your answer.
Binary program.
You specified a binary (executable) program or compiled Java class file. Enter a file name of a source program in the box.
Program as answer.
You submitted a program source file as an answer file. Enter a file name of an answer file in the box.
Input as answer.
You submitted an input file as an answer file. Enter a file name of an answer file in the box.
Input as program.
You submitted an input file as a program file. Enter a file name of a program file in the box.
Previous answer.
You submitted an answer to the previous data. You should run your program with a new input file.
Submits in too short time.
The server stopped processing your submit since you made submits in less than 0.5 seconds.
えびちゃんが A、TAB が B、monkukui が C を読みます(開始直前の話し合いで元々の予定と担当が入れ替わりました。この時点で不穏)。
A の問題文が長くて、なかなか把握できません。
そんなのに数十分も掛けていると手汗や動悸が大変なことになります。
落ちつこうと B 問題に目をやる(ここ謎ムーブ)と、IP アドレス関連の問題らしいです。書いてある通りに実装がんばる系?(イメージ)
もう少し B を読むと、「IP アドレスの説明だけは英語で書くけど、問題文自体は IP アドレスを使って書くよ」とか書かれていて謎です。
IP アドレスってそんな表現能力なくない? 図とかが描かれていたので、エスパーが要求されていたのかもしれません。
この辺でようやく気づいたんですが、どうやら PC は用意されたものではなく各自のものを使うルールらしいです。
コンテスト開始時に電源をつけていてよかったらしいのですが、ルールを把握していませんでした。
慌ててバッグから Mac を取り出そうとしたのですが、混乱しており、ゲームボーイを取り出してしまいました(ドラえもん状態)*1。
つらくなって Slack を見てみる(不正でしょ)と、tsutaj から「1h18m 経ったけど AC まだ? 問題文の翻訳できた?」とメッセージが来ていました。
「競技中だから問題文の内容は教えられないよ」と返答したのですが、これはいろいろとおかしいです(別に問題文の内容は聞かれていない・不正をしつつもルールを気にしている)。
ところで、コンテスト開始以降 monkukui/TAB は無言だし、えびちゃん以外も進捗は芳しくないようです(会話をしようね)。
自チーム・他チームの AC 状況も知りません(順位表を見ようね)。
Slack 以外で PC を触った記憶もありません(コーディングをしようね)。
あと最後まで A 問題を把握していません(問題文を読もうね)。