diff --git a/decode-ways/decode-ways-tutorial.pdf b/decode-ways/decode-ways-tutorial.pdf new file mode 100644 index 0000000..2100c40 Binary files /dev/null and b/decode-ways/decode-ways-tutorial.pdf differ diff --git a/decode-ways/decode-ways-tutorial.tex b/decode-ways/decode-ways-tutorial.tex new file mode 100644 index 0000000..f798665 --- /dev/null +++ b/decode-ways/decode-ways-tutorial.tex @@ -0,0 +1,51 @@ +\documentclass[10pt]{article} +\usepackage[utf8]{inputenc} +\usepackage{amsmath,amsthm,amssymb} +\usepackage{fullpage} +\usepackage{url} +\pagenumbering{gobble} +\usepackage{hyperref} + +\title{ Tutorial: Decodificando Mensagens} +\author{Leetcode 91} +\date{} +\begin{document} +\maketitle +O problema pode ser resolvido utilizando uma abordagem de \textbf{programação dinâmica}, na qual calculamos, passo a passo, o número de formas possíveis de decodificar a sequência até cada posição. + +A ideia é que cada dígito (ou par de dígitos consecutivos) da sequência pode representar uma letra do alfabeto latino, desde que o valor correspondente esteja entre $1$ e $26$. Assim, precisamos contar todas as maneiras válidas de interpretar a sequência numérica. + +Definimos uma estrutura de DP com dois estados para cada posição $i$: +\begin{itemize} + \item $dp[i][0]$: número de mensagens possíveis terminando no caractere $i$ \textbf{quando o dígito atual não é concatenado} com o anterior; + \item $dp[i][1]$: número de mensagens possíveis terminando no caractere $i$ \textbf{quando o dígito atual é concatenado} com o anterior. +\end{itemize} + +A transição entre os estados é definida da seguinte forma: +\begin{itemize} + \item Se o dígito atual $s[i]$ está entre $1$ e $9$, ele pode ser interpretado como uma letra individual. Logo: + \[ + dp[i][0] = dp[i - 1][0] + dp[i - 1][1] + \] + \item Se a combinação dos dois últimos dígitos $s[i-1]s[i]$ forma um número entre $10$ e $26$, então esses dois dígitos podem ser interpretados como uma única letra: + \[ + dp[i][1] = dp[i - 2][0] + dp[i - 2][1] + \] +\end{itemize} + +A base da recorrência é: +\[ +dp[0][0] = 1, \quad dp[0][1] = 0, \quad dp[1][0] = 1, \quad dp[1][1] = 0 +\] +pois antes de processar qualquer caractere há exatamente uma maneira “vazia” de formar uma mensagem válida, e o primeiro dígito pode, no máximo, representar uma única letra isolada. + +O resultado final é dado pela soma: + +\[ +dp[n][0] + dp[n][1] +\] + +onde $n$ é o comprimento da sequência de entrada. + +Essa solução possui complexidade de tempo e espaço $O(n)$, podendo ser otimizada para $O(1)$ espaço se armazenarmos apenas os últimos dois estados necessários para o cálculo. +\end{document} diff --git a/decode-ways/decode-ways.pdf b/decode-ways/decode-ways.pdf index 3a75583..75881b1 100644 Binary files a/decode-ways/decode-ways.pdf and b/decode-ways/decode-ways.pdf differ diff --git a/decode-ways/input/10 b/decode-ways/input/10 index a7b2a6a..82e7cdc 100644 --- a/decode-ways/input/10 +++ b/decode-ways/input/10 @@ -1,2 +1,2 @@ -2 -91 +5 +37679 diff --git a/decode-ways/input/100 b/decode-ways/input/100 index d962bdb..9ebdd4a 100644 --- a/decode-ways/input/100 +++ b/decode-ways/input/100 @@ -1,2 +1,2 @@ -48 -518576418188343163835239258872334287663796652624 +39 +926784174771952776334684785835183413371 diff --git a/decode-ways/input/101 b/decode-ways/input/101 index a75a307..eb68417 100644 --- a/decode-ways/input/101 +++ b/decode-ways/input/101 @@ -1,2 +1,2 @@ -68 -52611796735121263614334491834993887664736392163582841633871161326664 +87 +289464652164533976872545264322123756175737932929933941773473296396874643587186562586223 diff --git a/decode-ways/input/102 b/decode-ways/input/102 index ed28579..efe61f1 100644 --- a/decode-ways/input/102 +++ b/decode-ways/input/102 @@ -1,2 +1,2 @@ -53 -78918262129187186226632721586627412359187439651896536 +50 +88568481414945636815725155825841475572525196793844 diff --git a/decode-ways/input/103 b/decode-ways/input/103 index c8341f3..d962bdb 100644 --- a/decode-ways/input/103 +++ b/decode-ways/input/103 @@ -1,2 +1,2 @@ -82 -1472422558528699249214744131191854224759984764314392981892686621213825459276764139 +48 +518576418188343163835239258872334287663796652624 diff --git a/decode-ways/input/104 b/decode-ways/input/104 index 65f4a72..a75a307 100644 --- a/decode-ways/input/104 +++ b/decode-ways/input/104 @@ -1,2 +1,2 @@ -75 -337487917337778439116484693776643462673224333737181491845687417121878438442 +68 +52611796735121263614334491834993887664736392163582841633871161326664 diff --git a/decode-ways/input/105 b/decode-ways/input/105 index fd8815c..ed28579 100644 --- a/decode-ways/input/105 +++ b/decode-ways/input/105 @@ -1,2 +1,2 @@ -48 -963474156832317453372274752839831748129848526892 +53 +78918262129187186226632721586627412359187439651896536 diff --git a/decode-ways/input/106 b/decode-ways/input/106 index 7a4d5f6..c8341f3 100644 --- a/decode-ways/input/106 +++ b/decode-ways/input/106 @@ -1,2 +1,2 @@ -100 -1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +82 +1472422558528699249214744131191854224759984764314392981892686621213825459276764139 diff --git a/decode-ways/input/107 b/decode-ways/input/107 index a9938e1..65f4a72 100644 --- a/decode-ways/input/107 +++ b/decode-ways/input/107 @@ -1,2 +1,2 @@ -100 -0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +75 +337487917337778439116484693776643462673224333737181491845687417121878438442 diff --git a/decode-ways/input/108 b/decode-ways/input/108 new file mode 100644 index 0000000..fd8815c --- /dev/null +++ b/decode-ways/input/108 @@ -0,0 +1,2 @@ +48 +963474156832317453372274752839831748129848526892 diff --git a/decode-ways/input/109 b/decode-ways/input/109 new file mode 100644 index 0000000..7a4d5f6 --- /dev/null +++ b/decode-ways/input/109 @@ -0,0 +1,2 @@ +100 +1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 diff --git a/decode-ways/input/11 b/decode-ways/input/11 index aaa8262..c28721c 100644 --- a/decode-ways/input/11 +++ b/decode-ways/input/11 @@ -1,2 +1,2 @@ -1 -9 +3 +966 diff --git a/decode-ways/input/110 b/decode-ways/input/110 new file mode 100644 index 0000000..a9938e1 --- /dev/null +++ b/decode-ways/input/110 @@ -0,0 +1,2 @@ +100 +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 diff --git a/decode-ways/input/12 b/decode-ways/input/12 index ee9b571..00af0c7 100644 --- a/decode-ways/input/12 +++ b/decode-ways/input/12 @@ -1,2 +1,2 @@ -2 -16 +3 +999 diff --git a/decode-ways/input/13 b/decode-ways/input/13 index 8ba5333..a7b2a6a 100644 --- a/decode-ways/input/13 +++ b/decode-ways/input/13 @@ -1,2 +1,2 @@ -4 -2388 +2 +91 diff --git a/decode-ways/input/15 b/decode-ways/input/15 index 26b37d0..ee9b571 100644 --- a/decode-ways/input/15 +++ b/decode-ways/input/15 @@ -1,2 +1,2 @@ -1 -5 +2 +16 diff --git a/decode-ways/input/16 b/decode-ways/input/16 index e68c1c3..8ba5333 100644 --- a/decode-ways/input/16 +++ b/decode-ways/input/16 @@ -1,2 +1,2 @@ -3 -467 +4 +2388 diff --git a/decode-ways/input/17 b/decode-ways/input/17 index fa66b14..aaa8262 100644 --- a/decode-ways/input/17 +++ b/decode-ways/input/17 @@ -1,2 +1,2 @@ -5 -42142 +1 +9 diff --git a/decode-ways/input/18 b/decode-ways/input/18 index 2b2f2e1..26b37d0 100644 --- a/decode-ways/input/18 +++ b/decode-ways/input/18 @@ -1,2 +1,2 @@ 1 -3 +5 diff --git a/decode-ways/input/19 b/decode-ways/input/19 index 4caaa42..e68c1c3 100644 --- a/decode-ways/input/19 +++ b/decode-ways/input/19 @@ -1,2 +1,2 @@ -5 -51865 +3 +467 diff --git a/decode-ways/input/20 b/decode-ways/input/20 index d0fdcda..fa66b14 100644 --- a/decode-ways/input/20 +++ b/decode-ways/input/20 @@ -1,2 +1,2 @@ -2 -27 +5 +42142 diff --git a/decode-ways/input/21 b/decode-ways/input/21 index ba8c7c5..2b2f2e1 100644 --- a/decode-ways/input/21 +++ b/decode-ways/input/21 @@ -1,2 +1,2 @@ -2 -46 +1 +3 diff --git a/decode-ways/input/22 b/decode-ways/input/22 index 5281531..4caaa42 100644 --- a/decode-ways/input/22 +++ b/decode-ways/input/22 @@ -1,2 +1,2 @@ 5 -88626 +51865 diff --git a/decode-ways/input/23 b/decode-ways/input/23 index 5220a6e..d0fdcda 100644 --- a/decode-ways/input/23 +++ b/decode-ways/input/23 @@ -1,2 +1,2 @@ -5 -55673 +2 +27 diff --git a/decode-ways/input/24 b/decode-ways/input/24 index 3fefbe6..ba8c7c5 100644 --- a/decode-ways/input/24 +++ b/decode-ways/input/24 @@ -1,2 +1,2 @@ -4 -4647 +2 +46 diff --git a/decode-ways/input/25 b/decode-ways/input/25 index edb1539..5281531 100644 --- a/decode-ways/input/25 +++ b/decode-ways/input/25 @@ -1,2 +1,2 @@ 5 -79735 +88626 diff --git a/decode-ways/input/26 b/decode-ways/input/26 index c22514e..5220a6e 100644 --- a/decode-ways/input/26 +++ b/decode-ways/input/26 @@ -1,2 +1,2 @@ -3 -488 +5 +55673 diff --git a/decode-ways/input/27 b/decode-ways/input/27 index 504e241..3fefbe6 100644 --- a/decode-ways/input/27 +++ b/decode-ways/input/27 @@ -1,2 +1,2 @@ 4 -8282 +4647 diff --git a/decode-ways/input/28 b/decode-ways/input/28 index 6d4db54..edb1539 100644 --- a/decode-ways/input/28 +++ b/decode-ways/input/28 @@ -1,2 +1,2 @@ -3 -453 +5 +79735 diff --git a/decode-ways/input/29 b/decode-ways/input/29 index 20e3572..c22514e 100644 --- a/decode-ways/input/29 +++ b/decode-ways/input/29 @@ -1,2 +1,2 @@ -4 -2554 +3 +488 diff --git a/decode-ways/input/30 b/decode-ways/input/30 index 74d702d..504e241 100644 --- a/decode-ways/input/30 +++ b/decode-ways/input/30 @@ -1,2 +1,2 @@ 4 -2859 +8282 diff --git a/decode-ways/input/31 b/decode-ways/input/31 index ac45d7a..6d4db54 100644 --- a/decode-ways/input/31 +++ b/decode-ways/input/31 @@ -1,2 +1,2 @@ 3 -568 +453 diff --git a/decode-ways/input/32 b/decode-ways/input/32 index 3cdbd27..20e3572 100644 --- a/decode-ways/input/32 +++ b/decode-ways/input/32 @@ -1,2 +1,2 @@ 4 -7752 +2554 diff --git a/decode-ways/input/33 b/decode-ways/input/33 index 59384ea..74d702d 100644 --- a/decode-ways/input/33 +++ b/decode-ways/input/33 @@ -1,2 +1,2 @@ -2 -22 +4 +2859 diff --git a/decode-ways/input/34 b/decode-ways/input/34 index 3dea9c6..ac45d7a 100644 --- a/decode-ways/input/34 +++ b/decode-ways/input/34 @@ -1,2 +1,2 @@ -4 -3151 +3 +568 diff --git a/decode-ways/input/35 b/decode-ways/input/35 index 4ca1765..3cdbd27 100644 --- a/decode-ways/input/35 +++ b/decode-ways/input/35 @@ -1,2 +1,2 @@ -3 -876 +4 +7752 diff --git a/decode-ways/input/36 b/decode-ways/input/36 index f87272b..59384ea 100644 --- a/decode-ways/input/36 +++ b/decode-ways/input/36 @@ -1,2 +1,2 @@ -3 -343 +2 +22 diff --git a/decode-ways/input/37 b/decode-ways/input/37 index dfd4d44..3dea9c6 100644 --- a/decode-ways/input/37 +++ b/decode-ways/input/37 @@ -1,2 +1,2 @@ -5 -18499 +4 +3151 diff --git a/decode-ways/input/38 b/decode-ways/input/38 index 26b37d0..4ca1765 100644 --- a/decode-ways/input/38 +++ b/decode-ways/input/38 @@ -1,2 +1,2 @@ -1 -5 +3 +876 diff --git a/decode-ways/input/39 b/decode-ways/input/39 index da6c4af..f87272b 100644 --- a/decode-ways/input/39 +++ b/decode-ways/input/39 @@ -1,2 +1,2 @@ -14 -37196832511826 +3 +343 diff --git a/decode-ways/input/40 b/decode-ways/input/40 index c0e21ce..dfd4d44 100644 --- a/decode-ways/input/40 +++ b/decode-ways/input/40 @@ -1,2 +1,2 @@ -14 -64484224997944 +5 +18499 diff --git a/decode-ways/input/41 b/decode-ways/input/41 index 7f2e2b5..26b37d0 100644 --- a/decode-ways/input/41 +++ b/decode-ways/input/41 @@ -1,2 +1,2 @@ +1 5 -24949 diff --git a/decode-ways/input/42 b/decode-ways/input/42 index ebf09fd..da6c4af 100644 --- a/decode-ways/input/42 +++ b/decode-ways/input/42 @@ -1,2 +1,2 @@ -17 -37294479837671427 +14 +37196832511826 diff --git a/decode-ways/input/43 b/decode-ways/input/43 index 7e8e16d..c0e21ce 100644 --- a/decode-ways/input/43 +++ b/decode-ways/input/43 @@ -1,2 +1,2 @@ -16 -8428292392363723 +14 +64484224997944 diff --git a/decode-ways/input/44 b/decode-ways/input/44 index b71a0dd..7f2e2b5 100644 --- a/decode-ways/input/44 +++ b/decode-ways/input/44 @@ -1,2 +1,2 @@ -18 -273528536665319655 +5 +24949 diff --git a/decode-ways/input/45 b/decode-ways/input/45 index 369de6f..ebf09fd 100644 --- a/decode-ways/input/45 +++ b/decode-ways/input/45 @@ -1,2 +1,2 @@ -20 -24719734762578639371 +17 +37294479837671427 diff --git a/decode-ways/input/46 b/decode-ways/input/46 index 1191247..7e8e16d 100644 --- a/decode-ways/input/46 +++ b/decode-ways/input/46 @@ -1,2 +1,2 @@ -1 -2 +16 +8428292392363723 diff --git a/decode-ways/input/47 b/decode-ways/input/47 index 9cbe141..b71a0dd 100644 --- a/decode-ways/input/47 +++ b/decode-ways/input/47 @@ -1,2 +1,2 @@ -8 -15247334 +18 +273528536665319655 diff --git a/decode-ways/input/48 b/decode-ways/input/48 index 304801d..369de6f 100644 --- a/decode-ways/input/48 +++ b/decode-ways/input/48 @@ -1,2 +1,2 @@ -12 -136113183132 +20 +24719734762578639371 diff --git a/decode-ways/input/49 b/decode-ways/input/49 index 00af0c7..1191247 100644 --- a/decode-ways/input/49 +++ b/decode-ways/input/49 @@ -1,2 +1,2 @@ -3 -999 +1 +2 diff --git a/decode-ways/input/5 b/decode-ways/input/5 index 3e1e5e9..bbcc251 100644 --- a/decode-ways/input/5 +++ b/decode-ways/input/5 @@ -1,2 +1,2 @@ -9 -123456789 +20 +11111111111111111111 diff --git a/decode-ways/input/50 b/decode-ways/input/50 index b81c799..9cbe141 100644 --- a/decode-ways/input/50 +++ b/decode-ways/input/50 @@ -1,2 +1,2 @@ -19 -7241653425678432716 +8 +15247334 diff --git a/decode-ways/input/51 b/decode-ways/input/51 index ade753a..304801d 100644 --- a/decode-ways/input/51 +++ b/decode-ways/input/51 @@ -1,2 +1,2 @@ -20 -34126267846874316445 +12 +136113183132 diff --git a/decode-ways/input/52 b/decode-ways/input/52 index c8f627c..00af0c7 100644 --- a/decode-ways/input/52 +++ b/decode-ways/input/52 @@ -1,2 +1,2 @@ -2 -18 +3 +999 diff --git a/decode-ways/input/53 b/decode-ways/input/53 index 7cb0f0d..b81c799 100644 --- a/decode-ways/input/53 +++ b/decode-ways/input/53 @@ -1,2 +1,2 @@ -17 -84276873496766337 +19 +7241653425678432716 diff --git a/decode-ways/input/54 b/decode-ways/input/54 index cb032a5..ade753a 100644 --- a/decode-ways/input/54 +++ b/decode-ways/input/54 @@ -1,2 +1,2 @@ -19 -5958182244867784952 +20 +34126267846874316445 diff --git a/decode-ways/input/55 b/decode-ways/input/55 index 73d4067..c8f627c 100644 --- a/decode-ways/input/55 +++ b/decode-ways/input/55 @@ -1,2 +1,2 @@ -13 -9589633411419 +2 +18 diff --git a/decode-ways/input/56 b/decode-ways/input/56 index b72b8f8..7cb0f0d 100644 --- a/decode-ways/input/56 +++ b/decode-ways/input/56 @@ -1,2 +1,2 @@ -10 -8398213573 +17 +84276873496766337 diff --git a/decode-ways/input/57 b/decode-ways/input/57 index ee14444..cb032a5 100644 --- a/decode-ways/input/57 +++ b/decode-ways/input/57 @@ -1,2 +1,2 @@ -26 -73663332643446699323268217 +19 +5958182244867784952 diff --git a/decode-ways/input/58 b/decode-ways/input/58 index bbb80ab..73d4067 100644 --- a/decode-ways/input/58 +++ b/decode-ways/input/58 @@ -1,2 +1,2 @@ -51 -597752268768498572655986286986334279136111777165378 +13 +9589633411419 diff --git a/decode-ways/input/59 b/decode-ways/input/59 index bf1d363..b72b8f8 100644 --- a/decode-ways/input/59 +++ b/decode-ways/input/59 @@ -1,2 +1,2 @@ -9 -451285328 +10 +8398213573 diff --git a/decode-ways/input/6 b/decode-ways/input/6 index c5ac0a2..fcc4e19 100644 --- a/decode-ways/input/6 +++ b/decode-ways/input/6 @@ -1,2 +1,2 @@ -2 -82 +45 +111111111111111111111111111111111111111111111 diff --git a/decode-ways/input/60 b/decode-ways/input/60 index be97fe9..ee14444 100644 --- a/decode-ways/input/60 +++ b/decode-ways/input/60 @@ -1,2 +1,2 @@ -25 -5179694487483151683559695 +26 +73663332643446699323268217 diff --git a/decode-ways/input/61 b/decode-ways/input/61 index ec5a2aa..bbb80ab 100644 --- a/decode-ways/input/61 +++ b/decode-ways/input/61 @@ -1,2 +1,2 @@ -100 -8316458848752384176499983776724483328624123861532722553258433293959428726775271517961761959111789139 +51 +597752268768498572655986286986334279136111777165378 diff --git a/decode-ways/input/62 b/decode-ways/input/62 index 0b4407c..bf1d363 100644 --- a/decode-ways/input/62 +++ b/decode-ways/input/62 @@ -1,2 +1,2 @@ 9 -143311934 +451285328 diff --git a/decode-ways/input/63 b/decode-ways/input/63 index 92e83f4..be97fe9 100644 --- a/decode-ways/input/63 +++ b/decode-ways/input/63 @@ -1,2 +1,2 @@ -14 -56564483689558 +25 +5179694487483151683559695 diff --git a/decode-ways/input/64 b/decode-ways/input/64 index 5ecd584..ec5a2aa 100644 --- a/decode-ways/input/64 +++ b/decode-ways/input/64 @@ -1,2 +1,2 @@ -9 -255811985 +100 +8316458848752384176499983776724483328624123861532722553258433293959428726775271517961761959111789139 diff --git a/decode-ways/input/65 b/decode-ways/input/65 index 004f9d7..0b4407c 100644 --- a/decode-ways/input/65 +++ b/decode-ways/input/65 @@ -1,2 +1,2 @@ -50 -16741576977262376174576888714481988178418237879751 +9 +143311934 diff --git a/decode-ways/input/66 b/decode-ways/input/66 index 2b4fb32..92e83f4 100644 --- a/decode-ways/input/66 +++ b/decode-ways/input/66 @@ -1,2 +1,2 @@ -34 -7912496541424572969715221578743582 +14 +56564483689558 diff --git a/decode-ways/input/67 b/decode-ways/input/67 index 44e30a6..5ecd584 100644 --- a/decode-ways/input/67 +++ b/decode-ways/input/67 @@ -1,2 +1,2 @@ -66 -511181583562138544652879939619627143791253131734323199639644813935 +9 +255811985 diff --git a/decode-ways/input/68 b/decode-ways/input/68 index fb8b5ac..004f9d7 100644 --- a/decode-ways/input/68 +++ b/decode-ways/input/68 @@ -1,2 +1,2 @@ -23 -34741989276975341315688 +50 +16741576977262376174576888714481988178418237879751 diff --git a/decode-ways/input/69 b/decode-ways/input/69 index dcaf7fd..2b4fb32 100644 --- a/decode-ways/input/69 +++ b/decode-ways/input/69 @@ -1,2 +1,2 @@ -23 -45243179164459651875893 +34 +7912496541424572969715221578743582 diff --git a/decode-ways/input/7 b/decode-ways/input/7 index 82e7cdc..c1089f0 100644 --- a/decode-ways/input/7 +++ b/decode-ways/input/7 @@ -1,2 +1,2 @@ -5 -37679 +45 +111111111111111111111000000000000000000000000 diff --git a/decode-ways/input/70 b/decode-ways/input/70 index a6fefe0..44e30a6 100644 --- a/decode-ways/input/70 +++ b/decode-ways/input/70 @@ -1,2 +1,2 @@ -18 -698195955781719962 +66 +511181583562138544652879939619627143791253131734323199639644813935 diff --git a/decode-ways/input/71 b/decode-ways/input/71 index aae0ad8..fb8b5ac 100644 --- a/decode-ways/input/71 +++ b/decode-ways/input/71 @@ -1,2 +1,2 @@ -55 -7582648264398882877454489217294277449711166684383791147 +23 +34741989276975341315688 diff --git a/decode-ways/input/72 b/decode-ways/input/72 index 83ab6a2..dcaf7fd 100644 --- a/decode-ways/input/72 +++ b/decode-ways/input/72 @@ -1,2 +1,2 @@ -91 -3845152233572493744521853897783842761323223652968987664537616595428385811273627127469429381 +23 +45243179164459651875893 diff --git a/decode-ways/input/73 b/decode-ways/input/73 index 6ed281c..a6fefe0 100644 --- a/decode-ways/input/73 +++ b/decode-ways/input/73 @@ -1,2 +1,2 @@ -1 -1 +18 +698195955781719962 diff --git a/decode-ways/input/74 b/decode-ways/input/74 index 0eccae0..aae0ad8 100644 --- a/decode-ways/input/74 +++ b/decode-ways/input/74 @@ -1,2 +1,2 @@ -35 -37685246269847376739186534397615885 +55 +7582648264398882877454489217294277449711166684383791147 diff --git a/decode-ways/input/75 b/decode-ways/input/75 index 301e23d..83ab6a2 100644 --- a/decode-ways/input/75 +++ b/decode-ways/input/75 @@ -1,2 +1,2 @@ -33 -437232465386456746384257211614427 +91 +3845152233572493744521853897783842761323223652968987664537616595428385811273627127469429381 diff --git a/decode-ways/input/76 b/decode-ways/input/76 index 146dfbf..6ed281c 100644 --- a/decode-ways/input/76 +++ b/decode-ways/input/76 @@ -1,2 +1,2 @@ -77 -17627517227585432463647443411727297154114579897575441832469788516169223138766 +1 +1 diff --git a/decode-ways/input/77 b/decode-ways/input/77 index cd63ca7..0eccae0 100644 --- a/decode-ways/input/77 +++ b/decode-ways/input/77 @@ -1,2 +1,2 @@ -6 -236636 +35 +37685246269847376739186534397615885 diff --git a/decode-ways/input/78 b/decode-ways/input/78 index 6cc1b22..301e23d 100644 --- a/decode-ways/input/78 +++ b/decode-ways/input/78 @@ -1,2 +1,2 @@ -89 -56785878774135436521917749817518257767277569393487816624138298551327985724282322911471635 +33 +437232465386456746384257211614427 diff --git a/decode-ways/input/79 b/decode-ways/input/79 index 12fadaa..146dfbf 100644 --- a/decode-ways/input/79 +++ b/decode-ways/input/79 @@ -1,2 +1,2 @@ -22 -5368853232981964665459 +77 +17627517227585432463647443411727297154114579897575441832469788516169223138766 diff --git a/decode-ways/input/8 b/decode-ways/input/8 index c28721c..3e1e5e9 100644 --- a/decode-ways/input/8 +++ b/decode-ways/input/8 @@ -1,2 +1,2 @@ -3 -966 +9 +123456789 diff --git a/decode-ways/input/80 b/decode-ways/input/80 index ae23116..cd63ca7 100644 --- a/decode-ways/input/80 +++ b/decode-ways/input/80 @@ -1,2 +1,2 @@ -28 -3661945636959924865895846599 +6 +236636 diff --git a/decode-ways/input/81 b/decode-ways/input/81 index e8b7ddf..6cc1b22 100644 --- a/decode-ways/input/81 +++ b/decode-ways/input/81 @@ -1,2 +1,2 @@ -22 -9162867281853634311682 +89 +56785878774135436521917749817518257767277569393487816624138298551327985724282322911471635 diff --git a/decode-ways/input/82 b/decode-ways/input/82 index dde5b07..12fadaa 100644 --- a/decode-ways/input/82 +++ b/decode-ways/input/82 @@ -1,2 +1,2 @@ -54 -999497851484629835958949631491319582288263883695162451 +22 +5368853232981964665459 diff --git a/decode-ways/input/83 b/decode-ways/input/83 index 660c456..ae23116 100644 --- a/decode-ways/input/83 +++ b/decode-ways/input/83 @@ -1,2 +1,2 @@ -36 -966175859412534487161999147248815572 +28 +3661945636959924865895846599 diff --git a/decode-ways/input/84 b/decode-ways/input/84 index a60b2c2..e8b7ddf 100644 --- a/decode-ways/input/84 +++ b/decode-ways/input/84 @@ -1,2 +1,2 @@ -42 -173184196431757315622639898225196889893963 +22 +9162867281853634311682 diff --git a/decode-ways/input/85 b/decode-ways/input/85 index 1e15aa7..dde5b07 100644 --- a/decode-ways/input/85 +++ b/decode-ways/input/85 @@ -1,2 +1,2 @@ -97 -9566988274161314117748561711233529414952989568468244593491147579639921595125316948833947962993645 +54 +999497851484629835958949631491319582288263883695162451 diff --git a/decode-ways/input/86 b/decode-ways/input/86 index ef56fc5..660c456 100644 --- a/decode-ways/input/86 +++ b/decode-ways/input/86 @@ -1,2 +1,2 @@ -92 -41936458821482611656832918868813157673644393869888125877891312946217957114117772772821737554 +36 +966175859412534487161999147248815572 diff --git a/decode-ways/input/87 b/decode-ways/input/87 index d399af2..a60b2c2 100644 --- a/decode-ways/input/87 +++ b/decode-ways/input/87 @@ -1,2 +1,2 @@ -60 -897695728994154752385672625781113921437631223164657764585738 +42 +173184196431757315622639898225196889893963 diff --git a/decode-ways/input/88 b/decode-ways/input/88 index c18d3c8..1e15aa7 100644 --- a/decode-ways/input/88 +++ b/decode-ways/input/88 @@ -1,2 +1,2 @@ -47 -35839563993964564988114497921613189536194214699 +97 +9566988274161314117748561711233529414952989568468244593491147579639921595125316948833947962993645 diff --git a/decode-ways/input/89 b/decode-ways/input/89 index 1d2ec27..ef56fc5 100644 --- a/decode-ways/input/89 +++ b/decode-ways/input/89 @@ -1,2 +1,2 @@ -28 -5919482365125774713895541215 +92 +41936458821482611656832918868813157673644393869888125877891312946217957114117772772821737554 diff --git a/decode-ways/input/9 b/decode-ways/input/9 index 00af0c7..c5ac0a2 100644 --- a/decode-ways/input/9 +++ b/decode-ways/input/9 @@ -1,2 +1,2 @@ -3 -999 +2 +82 diff --git a/decode-ways/input/90 b/decode-ways/input/90 index 88c9d54..d399af2 100644 --- a/decode-ways/input/90 +++ b/decode-ways/input/90 @@ -1,2 +1,2 @@ -34 -5121266393832816569681656646982897 +60 +897695728994154752385672625781113921437631223164657764585738 diff --git a/decode-ways/input/91 b/decode-ways/input/91 index 25ab89c..c18d3c8 100644 --- a/decode-ways/input/91 +++ b/decode-ways/input/91 @@ -1,2 +1,2 @@ -44 -81585764841332967586694741428675158993386693 +47 +35839563993964564988114497921613189536194214699 diff --git a/decode-ways/input/92 b/decode-ways/input/92 index 5d388b6..1d2ec27 100644 --- a/decode-ways/input/92 +++ b/decode-ways/input/92 @@ -1,2 +1,2 @@ -35 -52822788191171594124666864915976567 +28 +5919482365125774713895541215 diff --git a/decode-ways/input/93 b/decode-ways/input/93 index 8987c8f..88c9d54 100644 --- a/decode-ways/input/93 +++ b/decode-ways/input/93 @@ -1,2 +1,2 @@ -47 -86971469847321526415492219574566459393276388723 +34 +5121266393832816569681656646982897 diff --git a/decode-ways/input/94 b/decode-ways/input/94 index 364f0c6..25ab89c 100644 --- a/decode-ways/input/94 +++ b/decode-ways/input/94 @@ -1,2 +1,2 @@ -19 -7541168218664593288 +44 +81585764841332967586694741428675158993386693 diff --git a/decode-ways/input/95 b/decode-ways/input/95 index 1033ecf..5d388b6 100644 --- a/decode-ways/input/95 +++ b/decode-ways/input/95 @@ -1,2 +1,2 @@ -43 -8963713375364717693949897694113372793124364 +35 +52822788191171594124666864915976567 diff --git a/decode-ways/input/96 b/decode-ways/input/96 index bad546a..8987c8f 100644 --- a/decode-ways/input/96 +++ b/decode-ways/input/96 @@ -1,2 +1,2 @@ -52 -8415242279691212836476114482582562535214174449485463 +47 +86971469847321526415492219574566459393276388723 diff --git a/decode-ways/input/97 b/decode-ways/input/97 index 9ebdd4a..364f0c6 100644 --- a/decode-ways/input/97 +++ b/decode-ways/input/97 @@ -1,2 +1,2 @@ -39 -926784174771952776334684785835183413371 +19 +7541168218664593288 diff --git a/decode-ways/input/98 b/decode-ways/input/98 index eb68417..1033ecf 100644 --- a/decode-ways/input/98 +++ b/decode-ways/input/98 @@ -1,2 +1,2 @@ -87 -289464652164533976872545264322123756175737932929933941773473296396874643587186562586223 +43 +8963713375364717693949897694113372793124364 diff --git a/decode-ways/input/99 b/decode-ways/input/99 index efe61f1..bad546a 100644 --- a/decode-ways/input/99 +++ b/decode-ways/input/99 @@ -1,2 +1,2 @@ -50 -88568481414945636815725155825841475572525196793844 +52 +8415242279691212836476114482582562535214174449485463 diff --git a/decode-ways/output/100 b/decode-ways/output/100 index 4d0e90c..f5c8955 100644 --- a/decode-ways/output/100 +++ b/decode-ways/output/100 @@ -1 +1 @@ -512 +32 diff --git a/decode-ways/output/101 b/decode-ways/output/101 index ec7b7d7..41c937d 100644 --- a/decode-ways/output/101 +++ b/decode-ways/output/101 @@ -1 +1 @@ -13824 +4608 diff --git a/decode-ways/output/102 b/decode-ways/output/102 index 7bcc8ab..d7b1c44 100644 --- a/decode-ways/output/102 +++ b/decode-ways/output/102 @@ -1 +1 @@ -5184 +1024 diff --git a/decode-ways/output/103 b/decode-ways/output/103 index 46f7274..4d0e90c 100644 --- a/decode-ways/output/103 +++ b/decode-ways/output/103 @@ -1 +1 @@ -663552 +512 diff --git a/decode-ways/output/104 b/decode-ways/output/104 index 693832e..ec7b7d7 100644 --- a/decode-ways/output/104 +++ b/decode-ways/output/104 @@ -1 +1 @@ -2880 +13824 diff --git a/decode-ways/output/105 b/decode-ways/output/105 index a949a93..7bcc8ab 100644 --- a/decode-ways/output/105 +++ b/decode-ways/output/105 @@ -1 +1 @@ -128 +5184 diff --git a/decode-ways/output/106 b/decode-ways/output/106 index 689d05f..46f7274 100644 --- a/decode-ways/output/106 +++ b/decode-ways/output/106 @@ -1 +1 @@ -1298777728820984005 +663552 diff --git a/decode-ways/output/107 b/decode-ways/output/107 index 573541a..693832e 100644 --- a/decode-ways/output/107 +++ b/decode-ways/output/107 @@ -1 +1 @@ -0 +2880 diff --git a/decode-ways/output/108 b/decode-ways/output/108 new file mode 100644 index 0000000..a949a93 --- /dev/null +++ b/decode-ways/output/108 @@ -0,0 +1 @@ +128 diff --git a/decode-ways/output/109 b/decode-ways/output/109 new file mode 100644 index 0000000..689d05f --- /dev/null +++ b/decode-ways/output/109 @@ -0,0 +1 @@ +1298777728820984005 diff --git a/decode-ways/output/110 b/decode-ways/output/110 new file mode 100644 index 0000000..573541a --- /dev/null +++ b/decode-ways/output/110 @@ -0,0 +1 @@ +0 diff --git a/decode-ways/output/12 b/decode-ways/output/12 index 0cfbf08..d00491f 100644 --- a/decode-ways/output/12 +++ b/decode-ways/output/12 @@ -1 +1 @@ -2 +1 diff --git a/decode-ways/output/13 b/decode-ways/output/13 index 0cfbf08..d00491f 100644 --- a/decode-ways/output/13 +++ b/decode-ways/output/13 @@ -1 +1 @@ -2 +1 diff --git a/decode-ways/output/15 b/decode-ways/output/15 index d00491f..0cfbf08 100644 --- a/decode-ways/output/15 +++ b/decode-ways/output/15 @@ -1 +1 @@ -1 +2 diff --git a/decode-ways/output/16 b/decode-ways/output/16 index d00491f..0cfbf08 100644 --- a/decode-ways/output/16 +++ b/decode-ways/output/16 @@ -1 +1 @@ -1 +2 diff --git a/decode-ways/output/17 b/decode-ways/output/17 index 00750ed..d00491f 100644 --- a/decode-ways/output/17 +++ b/decode-ways/output/17 @@ -1 +1 @@ -3 +1 diff --git a/decode-ways/output/19 b/decode-ways/output/19 index 0cfbf08..d00491f 100644 --- a/decode-ways/output/19 +++ b/decode-ways/output/19 @@ -1 +1 @@ -2 +1 diff --git a/decode-ways/output/20 b/decode-ways/output/20 index d00491f..00750ed 100644 --- a/decode-ways/output/20 +++ b/decode-ways/output/20 @@ -1 +1 @@ -1 +3 diff --git a/decode-ways/output/25 b/decode-ways/output/25 index d00491f..0cfbf08 100644 --- a/decode-ways/output/25 +++ b/decode-ways/output/25 @@ -1 +1 @@ -1 +2 diff --git a/decode-ways/output/29 b/decode-ways/output/29 index 0cfbf08..d00491f 100644 --- a/decode-ways/output/29 +++ b/decode-ways/output/29 @@ -1 +1 @@ -2 +1 diff --git a/decode-ways/output/32 b/decode-ways/output/32 index d00491f..0cfbf08 100644 --- a/decode-ways/output/32 +++ b/decode-ways/output/32 @@ -1 +1 @@ -1 +2 diff --git a/decode-ways/output/33 b/decode-ways/output/33 index 0cfbf08..d00491f 100644 --- a/decode-ways/output/33 +++ b/decode-ways/output/33 @@ -1 +1 @@ -2 +1 diff --git a/decode-ways/output/34 b/decode-ways/output/34 index 0cfbf08..d00491f 100644 --- a/decode-ways/output/34 +++ b/decode-ways/output/34 @@ -1 +1 @@ -2 +1 diff --git a/decode-ways/output/36 b/decode-ways/output/36 index d00491f..0cfbf08 100644 --- a/decode-ways/output/36 +++ b/decode-ways/output/36 @@ -1 +1 @@ -1 +2 diff --git a/decode-ways/output/39 b/decode-ways/output/39 index a45fd52..d00491f 100644 --- a/decode-ways/output/39 +++ b/decode-ways/output/39 @@ -1 +1 @@ -24 +1 diff --git a/decode-ways/output/40 b/decode-ways/output/40 index 00750ed..0cfbf08 100644 --- a/decode-ways/output/40 +++ b/decode-ways/output/40 @@ -1 +1 @@ -3 +2 diff --git a/decode-ways/output/41 b/decode-ways/output/41 index 0cfbf08..d00491f 100644 --- a/decode-ways/output/41 +++ b/decode-ways/output/41 @@ -1 +1 @@ -2 +1 diff --git a/decode-ways/output/42 b/decode-ways/output/42 index 0cfbf08..a45fd52 100644 --- a/decode-ways/output/42 +++ b/decode-ways/output/42 @@ -1 +1 @@ -2 +24 diff --git a/decode-ways/output/43 b/decode-ways/output/43 index 45a4fb7..00750ed 100644 --- a/decode-ways/output/43 +++ b/decode-ways/output/43 @@ -1 +1 @@ -8 +3 diff --git a/decode-ways/output/45 b/decode-ways/output/45 index 45a4fb7..0cfbf08 100644 --- a/decode-ways/output/45 +++ b/decode-ways/output/45 @@ -1 +1 @@ -8 +2 diff --git a/decode-ways/output/46 b/decode-ways/output/46 index d00491f..45a4fb7 100644 --- a/decode-ways/output/46 +++ b/decode-ways/output/46 @@ -1 +1 @@ -1 +8 diff --git a/decode-ways/output/47 b/decode-ways/output/47 index b8626c4..0cfbf08 100644 --- a/decode-ways/output/47 +++ b/decode-ways/output/47 @@ -1 +1 @@ -4 +2 diff --git a/decode-ways/output/48 b/decode-ways/output/48 index a45fd52..45a4fb7 100644 --- a/decode-ways/output/48 +++ b/decode-ways/output/48 @@ -1 +1 @@ -24 +8 diff --git a/decode-ways/output/5 b/decode-ways/output/5 index 00750ed..06a735b 100644 --- a/decode-ways/output/5 +++ b/decode-ways/output/5 @@ -1 +1 @@ -3 +10946 diff --git a/decode-ways/output/50 b/decode-ways/output/50 index b6a7d89..b8626c4 100644 --- a/decode-ways/output/50 +++ b/decode-ways/output/50 @@ -1 +1 @@ -16 +4 diff --git a/decode-ways/output/51 b/decode-ways/output/51 index 48082f7..a45fd52 100644 --- a/decode-ways/output/51 +++ b/decode-ways/output/51 @@ -1 +1 @@ -12 +24 diff --git a/decode-ways/output/52 b/decode-ways/output/52 index 0cfbf08..d00491f 100644 --- a/decode-ways/output/52 +++ b/decode-ways/output/52 @@ -1 +1 @@ -2 +1 diff --git a/decode-ways/output/53 b/decode-ways/output/53 index d00491f..b6a7d89 100644 --- a/decode-ways/output/53 +++ b/decode-ways/output/53 @@ -1 +1 @@ -1 +16 diff --git a/decode-ways/output/54 b/decode-ways/output/54 index 1e8b314..48082f7 100644 --- a/decode-ways/output/54 +++ b/decode-ways/output/54 @@ -1 +1 @@ -6 +12 diff --git a/decode-ways/output/55 b/decode-ways/output/55 index 1e8b314..0cfbf08 100644 --- a/decode-ways/output/55 +++ b/decode-ways/output/55 @@ -1 +1 @@ -6 +2 diff --git a/decode-ways/output/56 b/decode-ways/output/56 index 00750ed..d00491f 100644 --- a/decode-ways/output/56 +++ b/decode-ways/output/56 @@ -1 +1 @@ -3 +1 diff --git a/decode-ways/output/57 b/decode-ways/output/57 index a45fd52..1e8b314 100644 --- a/decode-ways/output/57 +++ b/decode-ways/output/57 @@ -1 +1 @@ -24 +6 diff --git a/decode-ways/output/58 b/decode-ways/output/58 index 52bd8e4..1e8b314 100644 --- a/decode-ways/output/58 +++ b/decode-ways/output/58 @@ -1 +1 @@ -120 +6 diff --git a/decode-ways/output/59 b/decode-ways/output/59 index 0cfbf08..00750ed 100644 --- a/decode-ways/output/59 +++ b/decode-ways/output/59 @@ -1 +1 @@ -2 +3 diff --git a/decode-ways/output/6 b/decode-ways/output/6 index d00491f..de22d67 100644 --- a/decode-ways/output/6 +++ b/decode-ways/output/6 @@ -1 +1 @@ -1 +1836311903 diff --git a/decode-ways/output/60 b/decode-ways/output/60 index 45a4fb7..a45fd52 100644 --- a/decode-ways/output/60 +++ b/decode-ways/output/60 @@ -1 +1 @@ -8 +24 diff --git a/decode-ways/output/61 b/decode-ways/output/61 index 6a0e31d..52bd8e4 100644 --- a/decode-ways/output/61 +++ b/decode-ways/output/61 @@ -1 +1 @@ -368640 +120 diff --git a/decode-ways/output/62 b/decode-ways/output/62 index 1e8b314..0cfbf08 100644 --- a/decode-ways/output/62 +++ b/decode-ways/output/62 @@ -1 +1 @@ -6 +2 diff --git a/decode-ways/output/63 b/decode-ways/output/63 index d00491f..45a4fb7 100644 --- a/decode-ways/output/63 +++ b/decode-ways/output/63 @@ -1 +1 @@ -1 +8 diff --git a/decode-ways/output/64 b/decode-ways/output/64 index 1e8b314..6a0e31d 100644 --- a/decode-ways/output/64 +++ b/decode-ways/output/64 @@ -1 +1 @@ -6 +368640 diff --git a/decode-ways/output/65 b/decode-ways/output/65 index d7b1c44..1e8b314 100644 --- a/decode-ways/output/65 +++ b/decode-ways/output/65 @@ -1 +1 @@ -1024 +6 diff --git a/decode-ways/output/66 b/decode-ways/output/66 index 52bd8e4..d00491f 100644 --- a/decode-ways/output/66 +++ b/decode-ways/output/66 @@ -1 +1 @@ -120 +1 diff --git a/decode-ways/output/67 b/decode-ways/output/67 index e0ea607..1e8b314 100644 --- a/decode-ways/output/67 +++ b/decode-ways/output/67 @@ -1 +1 @@ -11520 +6 diff --git a/decode-ways/output/68 b/decode-ways/output/68 index 45a4fb7..d7b1c44 100644 --- a/decode-ways/output/68 +++ b/decode-ways/output/68 @@ -1 +1 @@ -8 +1024 diff --git a/decode-ways/output/69 b/decode-ways/output/69 index b6a7d89..52bd8e4 100644 --- a/decode-ways/output/69 +++ b/decode-ways/output/69 @@ -1 +1 @@ -16 +120 diff --git a/decode-ways/output/7 b/decode-ways/output/7 index d00491f..573541a 100644 --- a/decode-ways/output/7 +++ b/decode-ways/output/7 @@ -1 +1 @@ -1 +0 diff --git a/decode-ways/output/70 b/decode-ways/output/70 index 45a4fb7..e0ea607 100644 --- a/decode-ways/output/70 +++ b/decode-ways/output/70 @@ -1 +1 @@ -8 +11520 diff --git a/decode-ways/output/71 b/decode-ways/output/71 index 3af99ee..45a4fb7 100644 --- a/decode-ways/output/71 +++ b/decode-ways/output/71 @@ -1 +1 @@ -180 +8 diff --git a/decode-ways/output/72 b/decode-ways/output/72 index 7bcc8ab..b6a7d89 100644 --- a/decode-ways/output/72 +++ b/decode-ways/output/72 @@ -1 +1 @@ -5184 +16 diff --git a/decode-ways/output/73 b/decode-ways/output/73 index d00491f..45a4fb7 100644 --- a/decode-ways/output/73 +++ b/decode-ways/output/73 @@ -1 +1 @@ -1 +8 diff --git a/decode-ways/output/74 b/decode-ways/output/74 index b6a7d89..3af99ee 100644 --- a/decode-ways/output/74 +++ b/decode-ways/output/74 @@ -1 +1 @@ -16 +180 diff --git a/decode-ways/output/75 b/decode-ways/output/75 index d15a2cc..7bcc8ab 100644 --- a/decode-ways/output/75 +++ b/decode-ways/output/75 @@ -1 +1 @@ -80 +5184 diff --git a/decode-ways/output/76 b/decode-ways/output/76 index 08ba12a..d00491f 100644 --- a/decode-ways/output/76 +++ b/decode-ways/output/76 @@ -1 +1 @@ -27648 +1 diff --git a/decode-ways/output/77 b/decode-ways/output/77 index 0cfbf08..b6a7d89 100644 --- a/decode-ways/output/77 +++ b/decode-ways/output/77 @@ -1 +1 @@ -2 +16 diff --git a/decode-ways/output/78 b/decode-ways/output/78 index 8f3aee4..d15a2cc 100644 --- a/decode-ways/output/78 +++ b/decode-ways/output/78 @@ -1 +1 @@ -73728 +80 diff --git a/decode-ways/output/79 b/decode-ways/output/79 index b8626c4..08ba12a 100644 --- a/decode-ways/output/79 +++ b/decode-ways/output/79 @@ -1 +1 @@ -4 +27648 diff --git a/decode-ways/output/8 b/decode-ways/output/8 index d00491f..00750ed 100644 --- a/decode-ways/output/8 +++ b/decode-ways/output/8 @@ -1 +1 @@ -1 +3 diff --git a/decode-ways/output/80 b/decode-ways/output/80 index b8626c4..0cfbf08 100644 --- a/decode-ways/output/80 +++ b/decode-ways/output/80 @@ -1 +1 @@ -4 +2 diff --git a/decode-ways/output/81 b/decode-ways/output/81 index 48082f7..8f3aee4 100644 --- a/decode-ways/output/81 +++ b/decode-ways/output/81 @@ -1 +1 @@ -12 +73728 diff --git a/decode-ways/output/82 b/decode-ways/output/82 index 9183bf0..b8626c4 100644 --- a/decode-ways/output/82 +++ b/decode-ways/output/82 @@ -1 +1 @@ -256 +4 diff --git a/decode-ways/output/83 b/decode-ways/output/83 index 86a0307..b8626c4 100644 --- a/decode-ways/output/83 +++ b/decode-ways/output/83 @@ -1 +1 @@ -192 +4 diff --git a/decode-ways/output/84 b/decode-ways/output/84 index bb7a7c1..48082f7 100644 --- a/decode-ways/output/84 +++ b/decode-ways/output/84 @@ -1 +1 @@ -576 +12 diff --git a/decode-ways/output/85 b/decode-ways/output/85 index 0d7be72..9183bf0 100644 --- a/decode-ways/output/85 +++ b/decode-ways/output/85 @@ -1 +1 @@ -51840 +256 diff --git a/decode-ways/output/86 b/decode-ways/output/86 index 5411448..86a0307 100644 --- a/decode-ways/output/86 +++ b/decode-ways/output/86 @@ -1 +1 @@ -279936 +192 diff --git a/decode-ways/output/87 b/decode-ways/output/87 index a0198be..bb7a7c1 100644 --- a/decode-ways/output/87 +++ b/decode-ways/output/87 @@ -1 +1 @@ -2400 +576 diff --git a/decode-ways/output/88 b/decode-ways/output/88 index a817176..0d7be72 100644 --- a/decode-ways/output/88 +++ b/decode-ways/output/88 @@ -1 +1 @@ -216 +51840 diff --git a/decode-ways/output/89 b/decode-ways/output/89 index 52bd8e4..5411448 100644 --- a/decode-ways/output/89 +++ b/decode-ways/output/89 @@ -1 +1 @@ -120 +279936 diff --git a/decode-ways/output/90 b/decode-ways/output/90 index f5c8955..a0198be 100644 --- a/decode-ways/output/90 +++ b/decode-ways/output/90 @@ -1 +1 @@ -32 +2400 diff --git a/decode-ways/output/91 b/decode-ways/output/91 index b6a7d89..a817176 100644 --- a/decode-ways/output/91 +++ b/decode-ways/output/91 @@ -1 +1 @@ -16 +216 diff --git a/decode-ways/output/92 b/decode-ways/output/92 index a29644e..52bd8e4 100644 --- a/decode-ways/output/92 +++ b/decode-ways/output/92 @@ -1 +1 @@ -144 +120 diff --git a/decode-ways/output/93 b/decode-ways/output/93 index eb08bc0..f5c8955 100644 --- a/decode-ways/output/93 +++ b/decode-ways/output/93 @@ -1 +1 @@ -240 +32 diff --git a/decode-ways/output/94 b/decode-ways/output/94 index ec63514..b6a7d89 100644 --- a/decode-ways/output/94 +++ b/decode-ways/output/94 @@ -1 +1 @@ -9 +16 diff --git a/decode-ways/output/95 b/decode-ways/output/95 index 7facc89..a29644e 100644 --- a/decode-ways/output/95 +++ b/decode-ways/output/95 @@ -1 +1 @@ -36 +144 diff --git a/decode-ways/output/96 b/decode-ways/output/96 index 0e3c600..eb08bc0 100644 --- a/decode-ways/output/96 +++ b/decode-ways/output/96 @@ -1 +1 @@ -5760 +240 diff --git a/decode-ways/output/97 b/decode-ways/output/97 index f5c8955..ec63514 100644 --- a/decode-ways/output/97 +++ b/decode-ways/output/97 @@ -1 +1 @@ -32 +9 diff --git a/decode-ways/output/98 b/decode-ways/output/98 index 41c937d..7facc89 100644 --- a/decode-ways/output/98 +++ b/decode-ways/output/98 @@ -1 +1 @@ -4608 +36 diff --git a/decode-ways/output/99 b/decode-ways/output/99 index d7b1c44..0e3c600 100644 --- a/decode-ways/output/99 +++ b/decode-ways/output/99 @@ -1 +1 @@ -1024 +5760 diff --git a/decode-ways/problem.json b/decode-ways/problem.json index 45ccff9..01f34f2 100644 --- a/decode-ways/problem.json +++ b/decode-ways/problem.json @@ -43,9 +43,9 @@ }, "solutions": { "main-ac": "ac.cpp", - "alternative-ac": [], + "alternative-ac": ["alternative_ac.cpp"], "wrong-answer": [], - "time-limit": [], + "time-limit": ["TLE.cpp"], "time-limit-or-ac": [], "time-limit-or-memory-limit": [], "memory-limit": [], diff --git a/decode-ways/src/TLE.cpp b/decode-ways/src/TLE.cpp new file mode 100644 index 0000000..e7ab352 --- /dev/null +++ b/decode-ways/src/TLE.cpp @@ -0,0 +1,40 @@ +#include + +typedef long long ll; +using namespace std; + +int ways(string &s, int n, int idx = 0) +{ + if (idx > n) + return 1; + if (s[idx] == '0') + return 0; + + int count = ways(s, n, idx + 1); + if (idx + 1 < n) + { + int num = stoi(s.substr(idx, 2)); + if (num >= 10 && num <= 26) + count += ways(s, n, idx + 2); + } + + return count; +} + +vector used; +int numDecodings(string &s) +{ + int n = (int)s.size(); + used.resize(n, false); + return ways(s, n); +} + +int main() +{ + int n; + cin >> n; + string code; + cin >> code; + cout << numDecodings(code) << endl; + return 0; +} \ No newline at end of file diff --git a/decode-ways/src/alternative_ac.cpp b/decode-ways/src/alternative_ac.cpp new file mode 100644 index 0000000..ed6c711 --- /dev/null +++ b/decode-ways/src/alternative_ac.cpp @@ -0,0 +1,45 @@ +#include + +typedef long long ll; +using namespace std; + +ll numDecodings(string s) +{ + if (s[0] == '0') + return 0; + + int N = s.size(); + ll dp1 = 1, dp2 = 1; + for (int i = 2; i <= N; i++) + { + ll next = 0; + char current = s[i - 1], last = s[i - 2]; + string aux = ""; + aux += last; + aux += current; + if (current != '0') + { + next = dp2; + } + + int code = stoi(aux); + if (10 <= code && code <= 26) + { + next += dp1; + } + swap(dp1, dp2); + swap(dp2, next); + } + + return dp2; +} + +int main() +{ + int n; + cin >> n; + string code; + cin >> code; + cout << numDecodings(code) << endl; + return 0; +} \ No newline at end of file diff --git a/decode-ways/src/generator.cpp b/decode-ways/src/generator.cpp index e2b6f5b..e47a844 100644 --- a/decode-ways/src/generator.cpp +++ b/decode-ways/src/generator.cpp @@ -30,6 +30,9 @@ vector generate_sample_tests() { vector generate_manual_tests() { vector tests; tests.push_back(output_tc("101010101010")); + tests.push_back(output_tc("11111111111111111111")); + tests.push_back(output_tc("111111111111111111111111111111111111111111111")); + tests.push_back(output_tc("111111111111111111111000000000000000000000000")); tests.push_back(output_tc("123456789")); return tests; } diff --git a/decode-ways/statement/tutorial.tex b/decode-ways/statement/tutorial.tex index e69de29..fe2dc74 100644 --- a/decode-ways/statement/tutorial.tex +++ b/decode-ways/statement/tutorial.tex @@ -0,0 +1,37 @@ +O problema pode ser resolvido utilizando uma abordagem de \textbf{programação dinâmica}, na qual calculamos, passo a passo, o número de formas possíveis de decodificar a sequência até cada posição. + +A ideia é que cada dígito (ou par de dígitos consecutivos) da sequência pode representar uma letra do alfabeto latino, desde que o valor correspondente esteja entre $1$ e $26$. Assim, precisamos contar todas as maneiras válidas de interpretar a sequência numérica. + +Definimos uma estrutura de DP com dois estados para cada posição $i$: +\begin{itemize} + \item $dp[i][0]$: número de mensagens possíveis terminando no caractere $i$ \textbf{quando o dígito atual não é concatenado} com o anterior; + \item $dp[i][1]$: número de mensagens possíveis terminando no caractere $i$ \textbf{quando o dígito atual é concatenado} com o anterior. +\end{itemize} + +A transição entre os estados é definida da seguinte forma: +\begin{itemize} + \item Se o dígito atual $s[i]$ está entre $1$ e $9$, ele pode ser interpretado como uma letra individual. Logo: + \[ + dp[i][0] = dp[i - 1][0] + dp[i - 1][1] + \] + \item Se a combinação dos dois últimos dígitos $s[i-1]s[i]$ forma um número entre $10$ e $26$, então esses dois dígitos podem ser interpretados como uma única letra: + \[ + dp[i][1] = dp[i - 2][0] + dp[i - 2][1] + \] +\end{itemize} + +A base da recorrência é: +\[ +dp[0][0] = 1, \quad dp[0][1] = 0, \quad dp[1][0] = 1, \quad dp[1][1] = 0 +\] +pois antes de processar qualquer caractere há exatamente uma maneira “vazia” de formar uma mensagem válida, e o primeiro dígito pode, no máximo, representar uma única letra isolada. + +O resultado final é dado pela soma: + +\[ +dp[n][0] + dp[n][1] +\] + +onde $n$ é o comprimento da sequência de entrada. + +Essa solução possui complexidade de tempo e espaço $O(n)$, podendo ser otimizada para $O(1)$ espaço se armazenarmos apenas os últimos dois estados necessários para o cálculo.