1504. Comptez les sous-concours avec tous ceux

DEV - 21/08
1504. Comptez les sous-concours avec toutes les difficultés: Sujets moyens: tableau, programmation dynamique, pile, ...

1504. Comptez les sous-concours avec tous ceux

Difficulté: moyen

Sujets:Tableau,Programmation dynamique,Empiler,Matrice,Pile monotone,Concours hebdomadaire 196

Donné unm x nmatrice binairetapis, renvoyez le nombre de sous-lambatrices qui en ont tous.

Exemple 1:

  • Entrée: MAT = [[1,0,1], [1,1,0], [1,1,0]]
  • Sortie: 13
  • Explication:
    • Il y a 6 rectangles du côté 1x1.
    • Il y a 2 rectangles du côté 1x2.
    • Il y a 3 rectangles du côté 2x1.
    • Il y a 1 rectangle du côté 2x2.
    • Il y a 1 rectangle du côté 3x1.
    • Nombre total de rectangles = 6 + 2 + 3 + 1 + 1 = 13.

Exemple 2:

  • Entrée: mat = [[0,1,1,0], [0,1,1,1], [1,1,1,0]]
  • Sortie: 24
  • Explication:
    • Il y a 8 rectangles du côté 1x1.
    • Il y a 5 rectangles du côté 1x2.
    • Il y a 2 rectangles du côté 1x3.
    • Il y a 4 rectangles du côté 2x1.
    • Il y a 2 rectangles...
      [Courte citation de 8% de l'article original]
Loading...