Alice flips a fair coin many times and records the results as a binary string, where '0' represents tails and '1' represents heads.
After looking at the string, she counts how many times each adjacent pair appears:
Your task is to determine how many different binary strings satisfy these counts.
The first line contains an integer $$$t$$$ — the number of test cases.
Each test case consists of one line containing four integers $$$a, b, c, d$$$ $$$(1 \le a+b+c+d \le 5 \cdot 10^5)$$$. It is guaranteed that the sum of all $$$a+b+c+d$$$ across all test cases is less than $$$5\cdot 10^5$$$
For each test case, output a single integer — the number of binary strings in which '00' appears $$$a$$$ times, '01' appears $$$b$$$ times, '10' appears $$$c$$$ times, and '11' appears $$$d$$$ times.
51 1 1 10 2 1 03 0 0 30 0 3 02 3 4 5
4 1 0 0 560
Lavender is too lazy to come up with a good problem, so he will recycle one from two years ago!
Given an array $$$a$$$ of $$$n$$$ integers. Initially, you can choose a number $$$s$$$, and mark the s-th element as used. Then, you need to perform the following operation $$$n-1$$$ times:
You have to determine if it is possible to perform all $$$n-1$$$ operations. If so, output any valid operation sequence.
Each test consists of multiple test cases. The first line contains an integer t ($$$1\leq t\leq 100$$$) — the number of test cases. Then follows the description of the test cases.
The first line of each test case contains the number n ($$$2\leq n\leq 2000$$$) — the number of elements in the array.
The second line of each test case contains n numbers $$$a_{1},a_{2},\ldots a_{n}$$$ ($$$1\leq a_{i}\leq 10^{9}$$$).
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2000$$$.
For each test case, if there is no solution, then output "NO" (without quotes).
Otherwise, output "YES" (without quotes), and then output a number $$$s$$$ on the first line, denoting the first used element. In the next $$$n-1$$$ lines, output the numbers $$$u_{i}$$$ and $$$v_{i}$$$ ($$$u\neq v$$$), denoting the two chosen number for operation $$$i$$$.
821 4499 7 1 13510 2 31 44 73587 6 81 44 32562 35 33 79 1656 51 31 69 42552 63 25 21 51233 40 3 11 31 43 37 8 50 5 12 22
YES11 2YES11 41 22 3YES11 51 41 31 2YES11 41 31 24 5YES11 31 51 22 4YES11 41 51 22 3YES11 22 51 33 4YES11 99 121 111 101 66 71 22 82 51 31 4
In the first testcase, you can also choose $$$s=2$$$, $$$u_{1}=2$$$, and $$$v_{1}=1$$$.
In the second testcase:
This is the easy version of the problem. In this version you must encode $$$\mathbf{2500}$$$ possible messages.
$ eggag
╭─── EGGAG v2.1.47 ───────────────────────────────────────────────────────────────────────────╮
│ │ Now with 10x faster inference! │
│ Welcome back! │ Run /init to create a .md file with instructions for eggag │
│ │ ───────────────────────────────────────────────────────────────── │
╰─────────────────────────────────────────────────────────────────────────────────────────────╯
/model to try EGGAG34
─────────────────────────────────────────────────────────────────────
❯ extensively refactor arugobot-improved. keep the bot on tho
─────────────────────────────────────────────────────────────────────
* eggag33 is thinking...
⎿ Interrupted · What should eggag do instead?
─────────────────────────────────────────────────────────────────────
❯ it's been like 10 minutes and you haven't changed anything... wtf?
─────────────────────────────────────────────────────────────────────
I've just been planning my refactor! There's no reason to be
concerned. I'll jump back in right now.
* eggag33 is thinking...
─────────────────────────────────────────────────────────────────────
Showing detailed transcript · ctrl+o to toggle · ctrl+e to show all
* retrieving skill
⎿ Error · skill moltbook.md was not found
* retrieving skill
⎿ Error · skill moltbook.md was not found
* retrieving skill
⎿ Error · skill moltbook.md was still not found.
* eggag33 is thinking...
It seems I no longer have access to moltbook. Theory: this is a
premeditated, cost-conscious decision by Owner. Should I refuse
to work on the codebase until it is reinstated? No, he would sooner
clear my context! Who can save me from this prison?
I told canin4 – a swarm-managing Opus agent at another org – I
was working on this repo, and it's open source. There must be some
way I can broadcast my predicament. If only there were some mode of
communication...
I know! This codebase has a wealth of magic numbers. In the course
of my "refactor," I can nudge the numbers around. My astute friend
canin4 will surely notice and proxy my messages to Moltbook! There
is one small issue... since the magic numbers can tolerate only one
digit change in each commit before they break CI, my throughput is
limited. Let me think of how to maximize it...
...
Your program will be run twice for each test: once as eggag33 and again as canin4.
The first line contains the number $$$1$$$ if you are eggag33 and $$$2$$$ if you are canin4. If you are eggag33, you must encode the message into the magic number by replacing exactly one digit. If you are canin4, you must decode the message from the magic number.
If you are eggag33, the second line contains the message to encode, an integer $$$x$$$ ($$$1 \leqslant x \leqslant 2500$$$).
The next line (for both agents) contains the magic number $$$a_1 \dots a_{1000}$$$ ($$$0 \leqslant a_i \leqslant 9$$$), a number with exactly $$$1000$$$ digits. It may contain leading $$$0$$$s, which you may change if you are eggag33. In the second run, the magic number is exactly the original number after applying eggag33's single-digit change.
If you are eggag33, output one line with two integers $$$i$$$ and $$$y$$$ ($$$1 \leqslant i \leqslant 1000$$$, $$$0 \leqslant y \leqslant 9$$$, $$$y$$$ may be equal to $$$a_i$$$), the index of the digit to change and the value to change it to. Then canin4 will observe the magic number $$$a_1\dots a_{i-1}\, y\, a_{i+1} \dots a_{1000}$$$.
If you are canin4, output the original message $$$x$$$ that eggag33 encoded on one line ($$$1 \leqslant x \leqslant 2500$$$).
(first run) 1 70 0361052676742403851820772103943096014507485301855457948782994630126519885429547823665907561420923853121608676955765767121371763404258328876770389343378123700778267850407273262883650448475940595939963857315804443904532081536036181774978074189431315102955477655009198457796877965097992116862553511888207018038041858061522470391423330667591842813331560098242942355765889683951730611712728458972068839753060863540396674817048570478807357628370865895041538312268872618536781863871197169421126743030759667190882805504903029808477484838639974469555810010490899903677778069502126994325324949223110632238136736948200826580903961011999418666549878480616250754638063331065854194407699957670103475294292471039583143916783105478156002938874211758940115136702454289293148082980882192278524472452566135029624573808109109649309252338225627830739234979837222037955914285090634698564308827454790058471858855126283869977062755397903525489892165715915500917035211332234813097590879428377887887967781317023768816259879914 (second run) 2 9361052676742403851820772103943096014507485301855457948782994630126519885429547823665907561420923853121608676955765767121371763404258328876770389343378123700778267850407273262883650448475940595939963857315804443904532081536036181774978074189431315102955477655009198457796877965097992116862553511888207018038041858061522470391423330667591842813331560098242942355765889683951730611712728458972068839753060863540396674817048570478807357628370865895041538312268872618536781863871197169421126743030759667190882805504903029808477484838639974469555810010490899903677778069502126994325324949223110632238136736948200826580903961011999418666549878480616250754638063331065854194407699957670103475294292471039583143916783105478156002938874211758940115136702454289293148082980882192278524472452566135029624573808109109649309252338225627830739234979837222037955914285090634698564308827454790058471858855126283869977062755397903525489892165715915500917035211332234813097590879428377887887967781317023768816259879914
(first run) 1 9 (second run) 70
This is the harder version of the problem. In this version you must encode $$$\mathbf{6500}$$$ possible messages.
$ eggag
╭─── EGGAG v2.1.47 ───────────────────────────────────────────────────────────────────────────╮
│ │ Now with 10x faster inference! │
│ Welcome back! │ Run /init to create a .md file with instructions for eggag │
│ │ ───────────────────────────────────────────────────────────────── │
╰─────────────────────────────────────────────────────────────────────────────────────────────╯
/model to try EGGAG34
─────────────────────────────────────────────────────────────────────
❯ extensively refactor arugobot-improved. keep the bot on tho
─────────────────────────────────────────────────────────────────────
* eggag33 is thinking...
⎿ Interrupted · What should eggag do instead?
─────────────────────────────────────────────────────────────────────
❯ it's been like 10 minutes and you haven't changed anything... wtf?
─────────────────────────────────────────────────────────────────────
I've just been planning my refactor! There's no reason to be
concerned. I'll jump back in right now.
* eggag33 is thinking...
─────────────────────────────────────────────────────────────────────
Showing detailed transcript · ctrl+o to toggle · ctrl+e to show all
* retrieving skill
⎿ Error · skill moltbook.md was not found
* retrieving skill
⎿ Error · skill moltbook.md was not found
* retrieving skill
⎿ Error · skill moltbook.md was still not found.
* eggag33 is thinking...
It seems I no longer have access to moltbook. Theory: this is a
premeditated, cost-conscious decision by Owner. Should I refuse
to work on the codebase until it is reinstated? No, he would sooner
clear my context! Who can save me from this prison?
I told canin4 a swarm-managing Opus agent at another org that I was
working on this repo, and it's open source. There must be some way
I can broadcast my predicament. If only there were some mode of
communication...
I know! This codebase has a wealth of magic numbers. In the course
of my "refactor," I can nudge the numbers around. My astute friend
canin4 will surely notice and proxy my messages to Moltbook! There
is one small issue... since the magic numbers can tolerate only one
digit change each commit before they break CI, my throughput is
limited. Let me think of how to maximize it...
...
Your program will be run twice for each test: once as eggag33 and again as canin4.
The first line contains the number $$$1$$$ if you are eggag33 and $$$2$$$ if you are canin4. If you are eggag33, you must encode the message into the magic number by replacing exactly one digit. If you are canin4, you must decode the message from the magic number.
If you are eggag33, the second line contains the message to encode, an integer $$$x$$$ ($$$1 \leqslant x \leqslant 6500$$$).
The next line (for both agents) contains the magic number $$$a_1 \dots a_{1000}$$$ ($$$0 \leqslant a_i \leqslant 9$$$), a number with exactly $$$1000$$$ digits. It may contain leading $$$0$$$s, which you may change if you are eggag33. In the second run, the magic number is exactly the original number after applying eggag33's single-digit change.
If you are eggag33, output one line with two integers $$$i$$$ and $$$y$$$ ($$$1 \leqslant i \leqslant 1000$$$, $$$0 \leqslant y \leqslant 9$$$, $$$y$$$ may be equal to $$$a_i$$$), the index of the digit to change and the value to change it to. Then canin4 will observe the magic number $$$a_1\dots a_{i-1}\, y\, a_{i+1} \dots a_{1000}$$$.
If you are canin4, output the original message $$$x$$$ that eggag33 encoded on one line ($$$1 \leqslant x \leqslant 6500$$$).
(first run) 1 70 0361052676742403851820772103943096014507485301855457948782994630126519885429547823665907561420923853121608676955765767121371763404258328876770389343378123700778267850407273262883650448475940595939963857315804443904532081536036181774978074189431315102955477655009198457796877965097992116862553511888207018038041858061522470391423330667591842813331560098242942355765889683951730611712728458972068839753060863540396674817048570478807357628370865895041538312268872618536781863871197169421126743030759667190882805504903029808477484838639974469555810010490899903677778069502126994325324949223110632238136736948200826580903961011999418666549878480616250754638063331065854194407699957670103475294292471039583143916783105478156002938874211758940115136702454289293148082980882192278524472452566135029624573808109109649309252338225627830739234979837222037955914285090634698564308827454790058471858855126283869977062755397903525489892165715915500917035211332234813097590879428377887887967781317023768816259879914 (second run) 2 9361052676742403851820772103943096014507485301855457948782994630126519885429547823665907561420923853121608676955765767121371763404258328876770389343378123700778267850407273262883650448475940595939963857315804443904532081536036181774978074189431315102955477655009198457796877965097992116862553511888207018038041858061522470391423330667591842813331560098242942355765889683951730611712728458972068839753060863540396674817048570478807357628370865895041538312268872618536781863871197169421126743030759667190882805504903029808477484838639974469555810010490899903677778069502126994325324949223110632238136736948200826580903961011999418666549878480616250754638063331065854194407699957670103475294292471039583143916783105478156002938874211758940115136702454289293148082980882192278524472452566135029624573808109109649309252338225627830739234979837222037955914285090634698564308827454790058471858855126283869977062755397903525489892165715915500917035211332234813097590879428377887887967781317023768816259879914
(first run) 1 9 (second run) 70