we are bc³. this is our website.

brown competitive coding club

we are the competitive coding club at brown.

we solve small, exact problems against a clock. for fun. on purpose.

we meet [REDACTED] in [REDACTED].

you do not have to be good at this. you have to be willing to be wrong in front of other people, which is how everyone here got good.

we can be reached at [REDACTED].

the bear is a cube, so the bear is a die. click it and this page rolls again.

we do these, mostly and these, when we want the statement to be four lines long start here if you have never done this or here, which holds your hand a little more we look things up here and here, when we have five terms and no ideas this is the one with the balloons

A. the bear is a cube

time limit: yours · memory limit: yours

the bear is building a tower. the footprint is 2×2, the tower is n tall, and every brick is 1×1×2. bricks may stand up or lie down. no gaps, nothing sticking out.

how many different towers are there, modulo 998244353? (a rotated tower is a different tower.)

n = 1  →  2
n = 2  →  9
n = 3  →  32
standings · 0:00:00
#who=Apen
1the bear1+
0:00
0
2you0.0
segment trees the number 998244353 problems that turn out to be binary search reading the constraints first
Previous Interests
  • treaps
  • writing a template library instead of practicing
  • python (time limit exceeded)
  • heavy-light decomposition
  • sqrt decomposition (somewhat current)
  • geometry (never again)
  • suffix automata
  • bitsets
  • blaming the judge
  • link-cut trees (nobody finished)
  • the convex hull trick
  • rust, briefly
what happens at a meeting? someone puts up a problem. it gets very quiet. eventually somebody says oh, and then they have to explain it to everyone else, which is the actual skill. then a harder one.
is this just leetcode? it's the next town over. an interview problem asks whether you have seen the trick before. a contest problem asks whether you can invent it in forty minutes, with n up to 2·105 and two teammates watching. after a while the first kind gets very quiet.
do i have to use c++? no. use whatever you like. most people end up there anyway, usually within a week of their first Time limit exceeded.
i have never done any of this good. you have no bad habits. we will lend you ours.
why is the bear a cube? b·c·c·c. also a cube tiles space, and bears, in general, do not.
how is this page laid out? badly, on purpose. every box here was thrown at a random spot and thrown again if it landed on another box. you are looking at layout , one of 4,294,967,296: boxes, rejected throws, ms. keep this one, or roll again.
hints for problem A
  1. for small n you can simply count. do that first. you will want the numbers.
  2. cut the tower between two layers. some bricks poke through the cut. there are only 24 ways for that to look.
  3. so one layer is a 16×16 matrix, n layers is that matrix to the n, and 1018 < 260.
  4. or stare at the small answers until a three-term recurrence falls out. we won't say which.
the eleven seconds between pressing submit and the verdict. wrong answer on test 2: the idea is wrong. wrong answer on test 47: the idea is right and you are wrong. explaining your solution out loud to a teammate and hearing the bug yourself, halfway through the sentence. the scoreboard freezing with an hour to go. everyone pretending to be calm. three people, one keyboard. a balloon going up over somebody else's table. n ≤ 10 → n! n ≤ 20 → 2n·n n ≤ 500 → n3 n ≤ 5000 → n2 n ≤ 2·105 → n log n n ≤ 1018 → log n, or a formula, or tears 998244353 = 119·223 + 1 109 + 7 is prime. so is 998244353. they are not the same prime. 231 − 1 = 2147483647. you will meet it. if you meet an O(n2) on the road, check the constraints before you kill it. read the problem.
read the problem.
read the problem.
it was binary search. it is usually binary search. the samples pass. the samples always pass. 108 a second. the rest is commentary. long long. Beware of bugs in the above code; I have only proved it correct, not tried it. — Knuth a dp walks into a bar. it has been here before. there are two kinds of people: those who index from 0, those who index from 1, and

bugs that have bitten us

int overflow off by one endl didn't reset between test cases n and m, swapped 1e9+7 (it was 998244353) uninitialized dp < (it was ≤) unordered_map read the wrong problem 1-indexed 0-indexed both array of size 1e5 (n was 2e5) % of a negative (lo + hi) / 2 int ans left the debug print in YES (it was Yes) comparator wasn't strict memset(a, 1, sizeof a) sqrt of a long long pow() returns a double multiset.erase(value) iterator invalidation there were t test cases recursion too deep forgot n = 1 the graph wasn't connected the graph wasn't simple subtracted, then modded, got −3 "at most", not "exactly" 2m edges, m slots the answer was 0 the answer didn't fit in a long long float cin, unsynced submitted to the wrong problem it was a multigraph stack-allocated 107 ints hashed mod 264