MagicTrickWithCards
TCO21 Round 4 · 2021-04-13 · by misof
Problem Statement
This problem involves test cases that are guaranteed to be random in some specific sense.
For this reason only test cases generated by us can be used. This means that there will only be a very limited opportunity to challenge other submissions for this problem.
------------------------
PART 1: THE DESCRIPTION OF A MAGIC TRICK
A magician gives the spectator the following instructions:
- Shuffle a deck of cards and place it on a table.
- Split it into three approximately equal piles: roughly the top third, the middle third, and the bottom third.
- Take a peek at the X-th card (0-based index) of the middle pile. That is now your card.
- Flip the middle pile upside down. (The cards now have faces pointing upwards. The face of the card that was touching the table is now visible on the top of the middle pile.)
- Collect the three piles, in their original order, to form one complete deck again. Keep the middle part upside down while you do so.
- Give the deck a single riffle shuffle (explained below).
- Flip the entire deck upside down.
- Give the deck one cut (explained below).
- Spread the cards to form one long line of cards, with the bottom card of the deck on the left and the top card on the right.
Once the spectator performs all these steps, the magician picks up one card from the table and shows it to the spectator with the usual question: "Is this your card?" The spectator confirms and the audience goes crazy.
A riffle shuffle is a shuffle in which the deck is split into two roughly equal halves - the top and the bottom half. Each half of the deck is held in one hand with the thumbs inward. Then, cards are released by the thumbs so that they fall to the table at an approximately same rate. The result is a deck in which the original top and bottom half are now approximately interleaved.
(A riffle shuffle preserves card orientations: cards that were face-down before the shuffle are still face-down and vice versa.)
A cut is an operation in which the spectator takes any number of cards from the top of the deck, places them aside, and then moves the rest of the deck on top of them. The new deck now consists of the bottom part of the original deck followed by its top part. The number of cards cut from the top is chosen by the spectator, the magician doesn't have any control over it. It can be zero.
------------------------
PART 2: THE PROBLEM YOU SHOULD SOLVE
Determine what the magician does to find the spectator's card and implement the magician's algorithm.
You are given a collection of queries.
In query number i, the cards on the table (as they were spread by the spectator in step 9) are represened by the
Note that all indices in this problem are 0-based, so queryX[i] = 0 means the specator peeked at the top card (of the middle third of the deck), queryX[i] = 1 was the card below the top card, and so on.
For each query, determine the (again, 0-based) index of the spectator's card in queryCards[i].
Return a
Your return value will be accepted if and only if it has at least 90 percent accuracy on each of the hidden test cases, and at least 50 percent accuracy on the example.
(There are exactly 20 other test cases. For each of them, your solution must correctly answer at least 45 out of the 50 queries it contains. For the example test case you must solve at least 10 out of the 20 queries.)
------------------------
PART 3: TECHNICAL DETAILS
There are exactly 52 cards in a standard deck, and there are exactly 52 uppercase and lowercase English letters ('A'-'Z', 'a'-'z'). Thus, we will use the letters to represent the cards in deck. (The exact mapping of letters to cards does not matter.)
Each queryCards[i] will be a string of 52 characters. Letters represent distinct cards that are visible to the magician, dashes ('-') are cards that are face-down.
For example, if queryCards[0] = "ncmN-z-yG--q-v-K-D-J-B--e----i-p-Q-s-F-d-ZjaxgfbOHAS", the magician sees a spread-out deck in which the bottom card is face-up (and has value 'n') and the top card is also face-up (and has value 'S'). Some of the other cards are currently face-down.
This problem is solvable with a much higher than required accuracy for any spectator that behaves according to the rules - in particular, in step 2 makes approximately equal piles and in step 6 performs a riffle shuffle that interleaves the two halves reasonably well.
This includes actual humans, which makes this a real-life magic trick you can perform at parties, once you learn how to do it.
One of the 20 non-example cases is available for download at the URL given below.
The correct answers for this test case are not provided, but as this is one of the actual test cases, you can use it as a challenge during the challenge phase.
- https://algo.sk/topcoder/MagicTrickWithCards/test.txt
As extra information that you may or may not use while solving the problem, pseudocode of the crucial steps of the generator used to generate the hidden tests is available here:
- https://algo.sk/topcoder/MagicTrickWithCards/generator.txt
One thousand other spread-out decks produced in step 9 by the same spectator who generated the actual hidden tests:
- https://algo.sk/topcoder/MagicTrickWithCards/1000.txt
Notes
- All test cases and all correct answers to hidden test cases were prepared by simulating a spectator that behaves as described in the problem statement.
- The answers shown as the example return value were manually modified to introduce mistakes.
- All hidden test cases were generated exactly once. All of the generated test cases were used, without any additional selection.
- The spectator can cut the deck as they like (not necessarily uniformly at random).
Constraints
- queryCards and queryX will have the same number of elements.
- For the example test case this number will be 20, for each of the other 20 test cases the number is 50.
- Each element of queryCards will be a string of exactly 52 letters and dashes.
- Each element of queryX will be between 0 and 4, inclusive.
{"ncmN-z-yG--q-v-K-D-J-B--e----i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2, 2, 1, 2, 1, 4, 4, 1, 1, 0, 0, 0, 2, 3, 3, 2, 4, 0, 2, 3}
Returns: {9, 5, 11, 23, 23, 1, 33, 14, 6, 23, 23, 4, 18, 0, 1, 27, 14, 51, 34, 16 }
The example answers are intentionally partially incorrect: only 13 out of these 20 are correct answers. This is still within the tolerance for the example test case, but a solution with an accuracy rate this low would fail on the hidden tests. Query 0 is the example deck mentioned in the statement.
{"h-i-y-LZ-o-I-v--Q-tDXFlJspwVCkWnPOdjf--R-N-Eg-b--U-H", "G-k-q-o-p-O-z-g-u-V-BYtHlJfaXZWjcAb-K--IL-w-T-U-v-x-", "-Q-O-E-n-x-t-JDVImTBHkdeCzZYRUgFXW-p--v-b-A-o-w-N-y-", "F-V-g--P-w-u-D-Q-e-JRlHAcIZrXBiMsTq-m-b-a-f-L-n-pv-z", "-k-zx-b-T-v-Vj--Bp-uOfRFshILGdg-W-SD-Q-q-aY-w-A--J-N", "xG-Y--C-F-O-h-V-A-TjNXcvWpPdMkmIzgD-o-i-s-H-r-J-B-w-", "-o-m-J-H--a-E-n-ywASltpcXQCqDZjFgVROKr-u-x-G--M-h-v-", "TA-B-E-y-a-F-C-h-f-pWqXbmgYIxsNPj-c-Vd-k-Z-e-R-G-i-H", "-K-w-j-d-S-H-v-u-B-n-gsIrcYVpXUMz-A-b--L-R-qQ-E-N-Z-", "SXj-g-N--K-b--E-V-Y--aHzFpRPvrTWGM-uL-f-s-O-q-t--D-d", "Z-g-m-D-U-v-F-cyRYMuxOTXIpeHzsoji-C-Q-bq-t-J---K-lL-", "--jy-FJ-W--lCtViXmfwbNLGIQkShTaoPMg-E--v-KR-p-A-q-s-", "H--Z-E-l-K-s--Y-jCwdVqbogmiURchkevN-P-p--tM-I-F-y-B-", "EI-S-d--C-B-y-U-so-F-Y-K-qPtcDNn-M-R-HG-kO-f-u-r-h-w", "rfX-t-TQ--o-B--sUpcmLOCGDAhJk-W-Ev-x-K-u-b--H-y-eN-Z", "TD-E--v-Hz--Z-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-b-G-J-C--R-g-Q-LHOluvzqywWINfThFpK-t-k--M-U-D-B-cA-", "--K-n-c-d-Y-O-aUBHEosJfthZkgbSvIDNRyLFlQ-u-x-j-i-r-M", "kyZ--z-h-S-m-x--r-I-ldufCwsaKBonAXjGHT-c-p--Eg-P-O-Y", "-cs-X--a-H-w-LIKmbglQWdZftOprkSNUAYTP-z-u-B-R-G-J-y-", "-q-fJ-K-Z-O-T-np-S-UrRvoAIjPMtNedly-g-u-Y--b-i-mV-c-", "tQo--a--G-cI--n-x-g-JuzWTrsOkbABSKmMf-E-NH-q--Ye-dp-", "-A--y-Q-Y-X-r-e-w-tbKMLHDoUWzhPERZ-CV-g--f-u-im-j-n-", "-x-u-KQ-nh-d-VE-B-ZtLaGewzDScbijPyN-o-rm--J-U-l-Y-R-", "zBU-H-L-P--D-K-aS-phuOMemlRgEbZx-W-q-V--CN-f-Q-vc-F-", "----T-b-q-kuKhLneGsmztDfiowyROBrCJdUj-S-A-Q-Y-g-c-x-", "W-M-U--HQ--O-G--D-n-iYwTejXgdRkSJslAb-N-hB-f-z-q-C-v", "x-b-y-f--k-rT-hEHOaeMjqmUtPgsBczWXnQ--lL--Y--dJ-F--p", "---H-Mg-Y-G--zyqnuUcRDImVEeQBahSXOlZNKpkPr--dF-t--L-", "--h--M-I-g-t-P-uSUTlNCFsbEYzcZopQBGk-V-d-L-i-HR--qA-", "---I-g-y--Tt-i-V-e-Z-UQYmSFEovzHxCMOcGh-u-j--La--N-p"}
{2, 1, 4, 4, 3, 3, 2, 4, 1, 0, 3, 4, 4, 0, 2, 3, 3, 0, 4, 0, 3, 3, 4, 0, 1, 1, 2, 0, 0, 4, 4, 1, 3, 3, 0, 0, 1, 0, 1, 1, 2, 4, 1, 4, 3, 0, 4, 4, 0, 3}
Returns: {14, 17, 4, 10, 11, 11, 11, 10, 18, 20, 7, 1, 8, 24, 11, 13, 13, 15, 4, 10, 8, 7, 4, 17, 16, 14, 15, 15, 18, 12, 12, 8, 9, 14, 16, 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vcTh-p-Ql", "--Y-VR---l-z-u-t-nA--I-od-HbLUgeBEkCDFiajwhPTy-r-X-N", "-D-R-X-----Q-u-CL-V-yeFdUhqmISJtoKGrsPpHBwgnY-Ol--c-", "u-Na--HDYjZr-G-U--l-n-s-g-h-CetEJzPKfdm-A-Si-X-o-Iv-", "-t--R-Uj-E-a-s-F--g-W-odpvrVhwuPkximLXKcOAI--J-M-q-n", "LN-t-b-x-i-B-fz-l--Qe-O-C-rGcUhPnSZjkKH-F-m-X-u-p-d-", "K-J-g-E--h-iT-y--LM-vNOudaRmFslYDpZbxtfASe--w-X--BP-", "--h-KX--z-d-T-G-E-wt--P-gWJNIyaAmievDnBxuY-p-k-j-Z-O", "-B-F--g-P--q-J--D-VY-n-ZpwfuKijLbyAvOlMrkXh-G-c-N--a", "j-u-mt-qw-od--vr-Cc--X-R-Z-KWznHghLGEfVb-kS-P-a-A--s", "--H-F-B-A-i--DC-r-k-e-ELnoUXvdzyKmbcjJu-wN-Q-O-Y-Z-p", "-C-O-L----r-N-p-Hnq-sJQAGiDbweohBjTIdykxUXc--F-t-EZ-"}
{1, 4, 0, 1, 0, 3, 0, 3, 3, 1, 1, 3, 4, 2, 1, 4, 4, 1, 3, 2, 4, 1, 1, 1, 1, 3, 0, 3, 0, 3, 0, 4, 3, 0, 3, 3, 4, 4, 4, 2, 3, 1, 1, 1, 2, 4, 1, 1, 1, 3}
Returns: {23, 11, 22, 21, 25, 13, 25, 19, 15, 20, 19, 21, 14, 15, 24, 19, 19, 22, 12, 18, 15, 23, 23, 22, 23, 14, 22, 14, 20, 17, 25, 14, 17, 19, 14, 20, 15, 16, 14, 20, 12, 25, 19, 23, 15, 15, 20, 24, 19, 11 }
{"Gd-A-n-lt--D-m-w-u-r---Uv-K--V-q--hMXFLBSJepOIkZiQfR", "CTWJXS-V-Q--k-pu--c---j-M-y-E-q-g-H-ZOKrFfozblLGhaxv", "izkL--A-y-m-Dl-I-o-UT-K-e-n-g-H-a-h-C-J-PbvuZBMsxpqY", "x-J-l-A-M-Y-W-v-h-G--r-e-D-E-d-V-a-gTfPZXHQqIBNpcSns", "qidMB-gV--W-jY-T-z--U-PQ-w-L--a-e-l-AJCnysEcfFXOxDok", "NLbByfn-Pi--l--M-Hp--G-vz-r-X-sE--Ja-Q-d-IZkTAetuFxg", "CuU-g-A-y-Sl-f-Y-K-vEW--eM--Nx--I-T--qz--DcVbjwrLXQR", "QPhX-e--V-y-jO--q-g---W-D-M-f-v-d-G-N-ctHlCZRBExTibY", "Z-Pq--T-Ud--p-Ot-e-KikBFD--w-j-V-N-g-sAlYGfQzCcumy-a", "nlz-h-v--PK-F--W-g-siR-c-Ab-T--x-p--mZUBYdLNOCJeEaVH", "IEs-it-O-G--JT--o-c--V--B-l--p--dyehuwXAmazCFZWfNjgk", "kR-H-p-A-w-l-O-jT-B-bn-i-s-Sy-X--qd-u-foPKDCFgrhtNxJ", "NEL-q--f-Yv-R--X-j------A-o-w-aP-xresZQMgcDCtpbmTHSG", "MKR-A-a--q-i-r-y-Y-Q--c-fD-lw--ku-tv-P-NxzXShHEOVJmn", "Wd-N-D-i--z-M-G-uX-JAqI-Y-f-K-l-m--O-RCUjBvZFytESsao", "-s--t-u-x-J-w-L--P-r-U-Hp-D-f-Eg-KndXNzvAFMVTGSCqOYl", "ldi-x-g-m-j--X-p-R-vr-I-y-c-O-W-N-auSEGkwAMeoYhQVfUP", "kwMyvA-S-D--L--Ng-s----E-q-Z--l-I-Y-baWuxJmitVhopefc", "ZCqbQUJ-y-pF--K--xO---i-Iv-H--m-sE-N-X-otrfVGcTanPgz", "-n-l-k-Eo--s-N-r-v-tQ-V-a-D-J-GH-i-S-UCWgRTumOZbwhey", "FdCSJ-O-h-w-X-G--v-c-----Q-y-WI-ZlBYVrHDaoUnumfNjRsb", "xq-G-V-h-Z--w-v-j--U---W-fm-J-F-d-nlYrNceXALQaCpokyi", "WAQU-m-P-q-E-z-Z-d-nH--pN-I-w-gl-y-hOKfRStBuMocDjCvF", "NSEm-l-e-U-a-H--P-uk-Gj-s-h-D-L-K-O-FgoXBqyiTnIcAtpw", "w-X-g-k-bt--d-B-Qc-G---JH-mL-z-py-l-KafIOheAoDVPZFxU", "S-I-t--gU-w-C-K-u-d--Ex--y-M-Pb--YT-WhXikBJcamqHVFjL", "R-X-S--D-V-J-u-w-a-OM-rd-B-n-U--y-A-T-pQzjKqxIevZmHs", "UOERb-p-F-AH-N-u-sK-cC--V-Q-m-W-j-L-JnBwTfqPMYDGegtX", "Mog--Y-xO-DC-X-z-T-ef-b-A-G-R-F-q--w-p-vSVZdJuUnaByW", "gacu--r-Uz--J-N-F--S--h-R-Li-l-E-CjbdVpwWsAvDmYByGkQ", "jmZyw-X-DG-z-K-vQ-o----O-P-i-u-CcHtrsTUSfeEdkYBbnMql", "U-e-v-O-a-uH-p-K-Y-VX--WS-gB-f-Zc-d-q--P-E-C-bkNmAx-", "td--ZN-T--e-R-p--UI----n-fl-V-S-mBaDEvOyqWugKFHMxcAC", "eRK-P-A-m-y-O-Z-M-YWX-l-o-T-cN-B-k-GC--sSzjqVuHLIwgh", "gZfrXE--e--Sk--N-WC---Y-L-M-Fa--lvywxcbuGhHoPnATsJOt", "cbDIGA-O-t--j-l-v-g-----h-n-N-HC-TrFasySJPEuzwXkUomL", "fvNmCBdH-w-Y-x-Kc--R-----M-l-VQ-On-J-EsgrbipSjzAqyaX", "dLVo-r-sY-l-a-CS---q-B-MO--j-Z-ey-hWzKbTmfEIcvRiJUuF", "WogPEjb-tO-y-w-R-D-perh-C-f-M--i-x--a-H-SLlVcZkuqnGA", "KqseZUn-B-v-Wt--b-c---u-T-y--P--FJVfAwpMjONYCiLxklgd", "-s-u-w-D-R-j-H-qI--WAmE-G-h-p-F-k-L-NreTvzaSlPxfXi-V", "XCbwj-v-A-M-U-L--r-T---d-af--Oh-JEYcgWpyQuGPSZResiFx", "LXGz-N-k-DT-p-i-c--Q--y-H--P-r-C-R-muvBoKYFhxjgEAOIs", "V-A--PZ-p-x-I-qS-y-bkflg-M-d-U-c-D-w-sGBjORXCnzKhaW-", "Xr-M-e-u-wj-d-L-q-O--l-s-k-n-Z-g-R-fiyQmpbEHTSxUNhVW", "UXR-o-F-Q-l-J-nu-Y-GDCIz-T-W--q-i-S-j-m-wOyehsKMadNv", "kEVcP-N--m--D-u-C-Q----i-x-f--n-bUlMaOwjFzsGZoqdevgL", "tE-o-c-y-a-b-p-U-PC-z-L--i-T-v-g-OB-x-wZHDYIsmeQrXKS", "Ms-V-Q-K-P--Wj-q-Y---I--on-i-Tt-a-f-pmeFHADdxLbwOUuB", "hZo-O-S-VT-n-f-i-x-rgJWc-R-M-q-A-G-t-PFlyBszejENXUCk"}
{1, 3, 4, 1, 0, 3, 0, 3, 4, 3, 0, 1, 4, 0, 3, 0, 4, 4, 2, 1, 0, 3, 4, 4, 0, 4, 4, 4, 2, 1, 1, 2, 4, 0, 3, 3, 1, 4, 4, 1, 0, 0, 2, 0, 0, 2, 4, 0, 0, 4}
Returns: {32, 29, 31, 32, 35, 33, 40, 31, 28, 30, 31, 35, 23, 38, 31, 32, 25, 28, 34, 34, 31, 27, 25, 27, 35, 26, 30, 27, 34, 30, 28, 40, 22, 38, 25, 25, 34, 25, 32, 30, 35, 31, 30, 36, 34, 35, 24, 37, 35, 28 }
{"dbCsHzt-g-p-w-S--vei-Of--ZQNhF--kB--K-L-U-xP-ruImRna", "xkTWRtUo-b-r-Q-G-Z-I-K-q-cD-v-O-l-E-J-A-f-a-m-pPFgwn", "yoQdUgRu--xB-T--NM-P-DI-s-z-O-H-X-hf--nC-lV-w-ZiJStv", "SjwVJXFkIbCDg-Nf-l--h-u--Tt--H-W-eR-A-y-Y-O-iUroMmqE", "YknbANS-e-U-O-V-a-C-R--r-Q--d-I-p-j-h-gJ--m-oxvfcLDZ", "xBVYzWHU-TM-D-Z-f-Q--m-d-e--P-h--v-w-Lp-S-OKabsJNrtG", "wChsOoy-S-F-X-R--q-K-T-W-u-x-e--I-MgN-b--QlHfJULZnkG", "ySgsq-o-Tp-e-z-VP-v-G-F-R-xY-J-OL-N-a-M-AfwniIQHZEKh", "jGmzERcfW--N-D--C-k-F-u-sY--xT-U-i--t-d-nhr-aBVoXLKl", "pybnQw-k-t-i-RI--K-NG-U--hHW--cm-x-e-q--BDCXSYEgzfsa", "MNfxpB-h-C-St--A-G--J-r--w---W-b-U-X-FZaHRLlsqvEgemP", "eLQfImNzp-C-F--H-V-w-K-h-O----X-Rt-D-B-i-U-vJsYdSPuW", "HbKCevns--k-U-Y-f-L-x-lh-y--G-t-oF-A-P-ER-p-TWjcwDqQ", "lYCnde-H-c-V-a-g-m--r-A-R----U-B-M-O-SJzsLipfujwyWEQ", "aEjeoV-vY-S-R-X-A-G-U-w-Q-cD-L--h-m-g-F-Z-byBCkpinsd", "hXzjPOMHva-Z--g-k-s-S-K-L--Y-y-W-e-i--u-E-RVdnFbxJcG", "LPbCXxZTlKu--k-c-D---A-z-t-----dH-I-qBneUsSwvEyJiFoV", "PqEBObSWil-t-p-r-x-D-H--U-A--Q-f--eC-R--dM-a-vGuZVXm", "DNKRh-k--Ig-p-a-jG--z-v-y---W-Q-b-S-qf-i-Y-FOlsLuTMr", "WZVzSBaTXCLIq-F-y-g-t-D-d-----v-m-co-p-fYsENlKJwGbUi", "swSDPK-W-m-L-U-eM-r-I-u-b--g-q-E-p-j-vZ--N-F-OzocYBC", "nqHYgkumfeT-d-O-Z-h-V--E-Ac-U-NJ--D-R-r-PQ-v-IlSWaiw", "MnfdcROWVvAo--k-p-F-CL-U---j--B-G--ZS-l-D-HYbTwymzaX", "TjQuOrIS-cL--W-v-q-RN--Y-Z--d-J-E-x-D-FH-aonGlymfBPU", "QAKgJCblLdoSj-P-yV--TY-Z-uhXRm-U-M-i--t--zE-e-a-GrBI", "bvCSD-Y-H-NT-Q-W-u-x-L-Ka-iz-B-R-s-k-j-o-y--M-XphtrP", "idFIYzKw-u-jS-X-l-N--U-H-y---s-k-Q-P-n-gbADeOfWmMToC", "tQibUcaBqoOZw-y-P-h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u-x-F-e-W-j--hC-v--f-a-tz-N-mZkpESAwRgBK", "CHgdNiK-V--W-k-t--U--G-yx--M-z-QcY--w-a-verhuPsXImRD", "TdQzCmYBZLeqRpVgIF--W-N--c---k-x-y-uo-v-n--A-MDalEfs"}
{1, 1, 1, 1, 1, 1, 3, 4, 2, 2, 2, 0, 3, 1, 2, 4, 4, 1, 2, 3, 4, 3, 0, 3, 1, 1, 3, 1, 4, 0, 3, 2, 4, 3, 3, 2, 2, 3, 3, 1, 4, 3, 4, 0, 3, 1, 2, 1, 2, 1}
Returns: {41, 43, 43, 41, 41, 39, 33, 30, 37, 36, 32, 42, 36, 34, 37, 34, 28, 42, 38, 31, 36, 37, 41, 33, 45, 43, 32, 39, 34, 40, 40, 40, 37, 36, 37, 40, 33, 35, 34, 39, 33, 34, 31, 40, 40, 38, 37, 37, 35, 42 }
Submissions are judged against all 23 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class MagicTrickWithCards with a public method vector<int> findTheirCard(vector<string> queryCards, vector<int> queryX) · 23 test cases · 2 s / 256 MB per case