QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#22320. Creare un lago

Statistics

Farmer John vuole aiuto dalle mucche per un lago. Mappa pascolo $R$ righe ($3\le R\le100$), $C$ colonne ($3\le C\le100$), quadrati sei per sei piedi, quota media in pollici ($10\le elev_{rc}\le5000$).

Allena «scavare pestando». Mandria robusta copre esattamente $3\times3$, va all’angolo alto sinistro $R_s,C_s$ ($1\le R_s\le R-2;1\le C_s\le C-2$), abbassa $D_s$ pollici ($1\le D_s\le40$). Mucche basse attendono altre al loro livello, quindi non tutte celle pestate o alcune meno.

Quote iniziali, $N$ istruzioni ordinate ($1\le N\le20000$), livello finale $E$ ($0\le E\le5000$): volume in pollici cubi, massimo $2,000,000,000$. Barriere ai bordi impediscono fuoriuscita.

Pascolo $4\times6$, quote con righe/colonne:

| Riga/colonna | $1$ | $2$ | $3$ | $4$ | $5$ | $6$ | | :---: | :---: | :---: | :---: | :---: | :---: | :---: | | $1$ | $28$ | $25$ | $20$ | $32$ | $34$ | $36$ | | $2$ | $27$ | $25$ | $20$ | $20$ | $30$ | $34$ | | $3$ | $24$ | $20$ | $20$ | $20$ | $20$ | $30$ | | $4$ | $20$ | $20$ | $14$ | $14$ | $20$ | $20$ |

Collina alto destra $36$, piccola alto sinistra $28$, lieve depressione mezzo riga $4$. Dopo "$1\;4\;4$":

| Riga | $1$ | $2$ | $3$ | $4$ | $5$ | $6$ | | :---: | :---: | :---: | :---: | :---: | :---: | :---: | | $1$ | $28$ | $25$ | $20$ | $32$ | $32$ | $32$ | | $2$ | $27$ | $25$ | $20$ | $20$ | $30$ | $32$ | | $3$ | $24$ | $20$ | $20$ | $20$ | $20$ | $30$ | | $4$ | $20$ | $20$ | $14$ | $14$ | $20$ | $20$ |

Solo tre celle scendono, sei altri gruppi aspettavano livello mai raggiunto. Dopo "$1\;1\;10$" alto sinistra:

| Riga | $1$ | $2$ | $3$ | $4$ | $5$ | $6$ | | :---: | :---: | :---: | :---: | :---: | :---: | :---: | | $1$ | $18$ | $18$ | $18$ | $32$ | $32$ | $32$ | | $2$ | $18$ | $18$ | $18$ | $20$ | $30$ | $32$ | | $3$ | $18$ | $18$ | $18$ | $20$ | $20$ | $30$ | | $4$ | $20$ | $20$ | $14$ | $14$ | $20$ | $20$ |

Livello $22$ pollici dà profondità:

| Riga | $1$ | $2$ | $3$ | $4$ | $5$ | $6$ | | :---: | :---: | :---: | :---: | :---: | :---: | :---: | | $1$ | $4$ | $4$ | $4$ | -- | -- | -- | | $2$ | $4$ | $4$ | $4$ | $2$ | -- | -- | | $3$ | $4$ | $4$ | $4$ | $2$ | $2$ | -- | | $4$ | $2$ | $2$ | $8$ | $8$ | $2$ | $2$ |

Somma $66$ per area sei per sei piedi: $66\times72\times72=342,144$ pollici cubi, lato $72$ pollici.

Scrivi programma automatico.

Input

  • Riga $1$: $R,C,E,N$ separati da spazi.

  • Righe $2,\ldots,R+1$: riga $i+1$, fila $i$ con $C$ interi separati da spazi.

  • Righe $R+2,\ldots,R+N+1$: riga $i+R+1$, istruzione $i$ con $R_s,C_s,D_s$.

Output

  • Riga 1: intero, volume del nuovo lago in pollici cubi.

Esempi

Input 1

4 6 22 2
28 25 20 32 34 36
27 25 20 20 30 34
24 20 20 20 20 30
20 20 14 14 20 20
1 4 4
1 1 10

Output 1

342144

Spiegazione

Come esempio del testo.

Autore: Rob Kolstad, 2008

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.