feat: added alternative python solutions.
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -43,7 +43,7 @@
|
||||
},
|
||||
"solutions": {
|
||||
"main-ac": "ac.cpp",
|
||||
"alternative-ac": ["alternative_ac.cpp"],
|
||||
"alternative-ac": ["alternative_ac.cpp", "alternative-ac2.py"],
|
||||
"wrong-answer": [],
|
||||
"time-limit": ["TLE.cpp"],
|
||||
"time-limit-or-ac": [],
|
||||
|
||||
16
decode-ways/src/alternative-ac2.py
Normal file
16
decode-ways/src/alternative-ac2.py
Normal file
@@ -0,0 +1,16 @@
|
||||
n = int(input())
|
||||
s = input().strip()
|
||||
|
||||
dp = [0] * (n + 1)
|
||||
dp[0] = 1
|
||||
|
||||
for i in range(1, n + 1):
|
||||
if s[i - 1] != '0':
|
||||
dp[i] += dp[i - 1]
|
||||
|
||||
if i > 1:
|
||||
two_digit = int(s[i - 2:i])
|
||||
if 10 <= two_digit <= 26:
|
||||
dp[i] += dp[i - 2]
|
||||
|
||||
print(dp[n])
|
||||
Binary file not shown.
Binary file not shown.
@@ -43,7 +43,7 @@
|
||||
},
|
||||
"solutions": {
|
||||
"main-ac": "ac.cpp",
|
||||
"alternative-ac": [],
|
||||
"alternative-ac": ["saad.py"],
|
||||
"wrong-answer": [],
|
||||
"time-limit": ["TLE.cpp"],
|
||||
"time-limit-or-ac": [],
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,7 +1,7 @@
|
||||
\documentclass{maratona}
|
||||
|
||||
\begin{document}
|
||||
\begin{ProblemaAutor}{}{Estouro}{1}{256}{Leetcode 312}
|
||||
\begin{ProblemaAutor}{}{Estouro}{1.5}{256}{Leetcode 312}
|
||||
|
||||
No laboratório de experimentos caóticos da \textbf{Fábrica de Balões Numéricos}, um cientista excêntrico te entrega uma fileira de balões, cada um pintado com um número inteiro positivo.
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"problem": {
|
||||
"title": "Estouro",
|
||||
"event": "",
|
||||
"time_limit": 1.0,
|
||||
"time_limit": 1.5,
|
||||
"memory_limit_mb": 256,
|
||||
"input_file": "stdin",
|
||||
"output_file": "stdout",
|
||||
@@ -43,7 +43,7 @@
|
||||
},
|
||||
"solutions": {
|
||||
"main-ac": "ac.cpp",
|
||||
"alternative-ac": [],
|
||||
"alternative-ac": ["alternative-ac.py"],
|
||||
"wrong-answer": [],
|
||||
"time-limit": [],
|
||||
"time-limit-or-ac": [],
|
||||
|
||||
31
estouro/src/alternative-ac.py
Normal file
31
estouro/src/alternative-ac.py
Normal file
@@ -0,0 +1,31 @@
|
||||
n = int(input())
|
||||
arr = list(map(int, input().split()))
|
||||
|
||||
nums = [1] + arr + [1]
|
||||
m = n + 2
|
||||
|
||||
dp = [[0] * m for _ in range(m)]
|
||||
|
||||
for length in range(2, m):
|
||||
for left in range(m - length):
|
||||
right = left + length
|
||||
|
||||
best = 0
|
||||
left_val = nums[left]
|
||||
right_val = nums[right]
|
||||
|
||||
row_left = dp[left]
|
||||
|
||||
for k in range(left + 1, right):
|
||||
val = (
|
||||
row_left[k]
|
||||
+ dp[k][right]
|
||||
+ left_val * nums[k] * right_val
|
||||
)
|
||||
|
||||
if val > best:
|
||||
best = val
|
||||
|
||||
row_left[right] = best
|
||||
|
||||
print(dp[0][m - 1])
|
||||
Binary file not shown.
Binary file not shown.
@@ -13,7 +13,7 @@ Bino está planejando o jardim e quer saber quantas opções de design ele realm
|
||||
|
||||
\Entrada
|
||||
|
||||
A entrada contém dois inteiros separados por espaço, \(n\) e \(m\), onde \(n\) (\(1 \leq n \leq 10\,000\)) é o comprimento da sequência de flores e \(m\) (\(1 \leq m \leq 1\,000\)) é o número máximo permitido de flores iguais consecutivas.
|
||||
A entrada contém dois inteiros separados por espaço, \(n\) e \(m\), onde \(n\) (\(1 \leq n \leq 1\,000\)) é o comprimento da sequência de flores e \(m\) (\(1 \leq m \leq 1\,000\)) é o número máximo permitido de flores iguais consecutivas.
|
||||
|
||||
\Saida
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
1497 202
|
||||
97 202
|
||||
|
||||
@@ -1 +1 @@
|
||||
7455 217
|
||||
455 217
|
||||
|
||||
@@ -1 +1 @@
|
||||
3590 343
|
||||
590 343
|
||||
|
||||
@@ -1 +1 @@
|
||||
4427 220
|
||||
427 220
|
||||
|
||||
@@ -1 +1 @@
|
||||
1342 584
|
||||
342 584
|
||||
|
||||
@@ -1 +1 @@
|
||||
4239 496
|
||||
239 496
|
||||
|
||||
@@ -1 +1 @@
|
||||
5875 601
|
||||
875 601
|
||||
|
||||
@@ -1 +1 @@
|
||||
10000 1
|
||||
1000 1
|
||||
|
||||
@@ -1 +1 @@
|
||||
10000 1000
|
||||
1000 1000
|
||||
|
||||
@@ -1 +1 @@
|
||||
1775 325
|
||||
175 325
|
||||
|
||||
@@ -1 +1 @@
|
||||
1982 784
|
||||
182 784
|
||||
|
||||
@@ -1 +1 @@
|
||||
417 156
|
||||
17 156
|
||||
|
||||
@@ -1 +1 @@
|
||||
1932 902
|
||||
132 902
|
||||
|
||||
@@ -1 +1 @@
|
||||
1728 537
|
||||
128 537
|
||||
|
||||
@@ -1 +1 @@
|
||||
1857 739
|
||||
57 739
|
||||
|
||||
@@ -1 +1 @@
|
||||
918 211
|
||||
118 211
|
||||
|
||||
@@ -1 +1 @@
|
||||
1679 506
|
||||
79 506
|
||||
|
||||
@@ -1 +1 @@
|
||||
1340 568
|
||||
140 568
|
||||
|
||||
@@ -1 +1 @@
|
||||
1868 16
|
||||
68 16
|
||||
|
||||
@@ -1 +1 @@
|
||||
1940 263
|
||||
140 263
|
||||
|
||||
@@ -1 +1 @@
|
||||
593 449
|
||||
193 449
|
||||
|
||||
@@ -1 +1 @@
|
||||
991 310
|
||||
191 310
|
||||
|
||||
@@ -1 +1 @@
|
||||
1355 68
|
||||
155 68
|
||||
|
||||
@@ -1 +1 @@
|
||||
1431 580
|
||||
31 580
|
||||
|
||||
@@ -1 +1 @@
|
||||
1757 218
|
||||
157 218
|
||||
|
||||
@@ -1 +1 @@
|
||||
934 328
|
||||
134 328
|
||||
|
||||
@@ -1 +1 @@
|
||||
1676 355
|
||||
76 355
|
||||
|
||||
@@ -1 +1 @@
|
||||
221 80
|
||||
21 80
|
||||
|
||||
@@ -1 +1 @@
|
||||
1922 545
|
||||
122 545
|
||||
|
||||
@@ -1 +1 @@
|
||||
511 67
|
||||
111 67
|
||||
|
||||
@@ -1 +1 @@
|
||||
1467 674
|
||||
67 674
|
||||
|
||||
@@ -1 +1 @@
|
||||
691 504
|
||||
91 504
|
||||
|
||||
@@ -1 +1 @@
|
||||
1835 34
|
||||
35 34
|
||||
|
||||
@@ -1 +1 @@
|
||||
965 980
|
||||
165 980
|
||||
|
||||
@@ -1 +1 @@
|
||||
1221 895
|
||||
21 895
|
||||
|
||||
@@ -1 +1 @@
|
||||
501 152
|
||||
101 152
|
||||
|
||||
@@ -1 +1 @@
|
||||
325 731
|
||||
125 731
|
||||
|
||||
@@ -1 +1 @@
|
||||
4302 153
|
||||
302 153
|
||||
|
||||
@@ -1 +1 @@
|
||||
4896 22
|
||||
396 22
|
||||
|
||||
@@ -1 +1 @@
|
||||
2489 399
|
||||
489 399
|
||||
|
||||
@@ -1 +1 @@
|
||||
607 466
|
||||
107 466
|
||||
|
||||
@@ -1 +1 @@
|
||||
4432 502
|
||||
432 502
|
||||
|
||||
@@ -1 +1 @@
|
||||
3968 333
|
||||
468 333
|
||||
|
||||
@@ -1 +1 @@
|
||||
2475 792
|
||||
475 792
|
||||
|
||||
@@ -1 +1 @@
|
||||
4694 328
|
||||
194 328
|
||||
|
||||
@@ -1 +1 @@
|
||||
2354 712
|
||||
354 712
|
||||
|
||||
@@ -1 +1 @@
|
||||
3409 480
|
||||
409 480
|
||||
|
||||
@@ -1 +1 @@
|
||||
2643 121
|
||||
143 121
|
||||
|
||||
@@ -1 +1 @@
|
||||
1951 492
|
||||
451 492
|
||||
|
||||
@@ -1 +1 @@
|
||||
4420 197
|
||||
420 197
|
||||
|
||||
@@ -1 +1 @@
|
||||
3607 925
|
||||
107 925
|
||||
|
||||
@@ -1 +1 @@
|
||||
2167 717
|
||||
167 717
|
||||
|
||||
@@ -1 +1 @@
|
||||
3438 200
|
||||
438 200
|
||||
|
||||
@@ -1 +1 @@
|
||||
6986 104
|
||||
986 104
|
||||
|
||||
@@ -1 +1 @@
|
||||
6483 620
|
||||
483 620
|
||||
|
||||
@@ -1 +1 @@
|
||||
9806 881
|
||||
806 881
|
||||
|
||||
@@ -1 +1 @@
|
||||
6858 559
|
||||
858 559
|
||||
|
||||
@@ -1 +1 @@
|
||||
522 575
|
||||
122 575
|
||||
|
||||
@@ -1 +1 @@
|
||||
6553 502
|
||||
553 502
|
||||
|
||||
@@ -1 +1 @@
|
||||
3554 962
|
||||
554 962
|
||||
|
||||
@@ -1 +1 @@
|
||||
2325 435
|
||||
325 435
|
||||
|
||||
@@ -1 +1 @@
|
||||
9279 464
|
||||
279 464
|
||||
|
||||
@@ -1 +1 @@
|
||||
7327 549
|
||||
327 549
|
||||
|
||||
@@ -1 +1 @@
|
||||
9832 595
|
||||
832 595
|
||||
|
||||
@@ -1 +1 @@
|
||||
8200 720
|
||||
200 720
|
||||
|
||||
@@ -1 +1 @@
|
||||
7658 639
|
||||
658 639
|
||||
|
||||
@@ -1 +1 @@
|
||||
9992 130
|
||||
992 130
|
||||
|
||||
@@ -1 +1 @@
|
||||
6467 989
|
||||
467 989
|
||||
|
||||
@@ -1 +1 @@
|
||||
426 445
|
||||
26 445
|
||||
|
||||
@@ -1 +1 @@
|
||||
7958 581
|
||||
958 581
|
||||
|
||||
@@ -1 +1 @@
|
||||
6600 466
|
||||
600 466
|
||||
|
||||
@@ -1 +1 @@
|
||||
1473 929
|
||||
473 929
|
||||
|
||||
@@ -1 +1 @@
|
||||
9775 581
|
||||
775 581
|
||||
|
||||
@@ -1 +1 @@
|
||||
9770 455
|
||||
770 455
|
||||
|
||||
@@ -1 +1 @@
|
||||
3718 628
|
||||
718 628
|
||||
|
||||
@@ -1 +1 @@
|
||||
6807 335
|
||||
807 335
|
||||
|
||||
@@ -1 +1 @@
|
||||
1898 552
|
||||
898 552
|
||||
|
||||
@@ -1 +1 @@
|
||||
6530 811
|
||||
530 811
|
||||
|
||||
@@ -1 +1 @@
|
||||
9569 148
|
||||
569 148
|
||||
|
||||
@@ -1 +1 @@
|
||||
772 81
|
||||
172 81
|
||||
|
||||
@@ -1 +1 @@
|
||||
3384 954
|
||||
384 954
|
||||
|
||||
@@ -1 +1 @@
|
||||
8913 114
|
||||
913 114
|
||||
|
||||
@@ -1 +1 @@
|
||||
6315 686
|
||||
315 686
|
||||
|
||||
@@ -1 +1 @@
|
||||
9334 382
|
||||
334 382
|
||||
|
||||
@@ -1 +1 @@
|
||||
1392 326
|
||||
392 326
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user