# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
68270 | 2018-08-16T10:46:29 Z | AdrienVannson | Cultivation (JOI17_cultivation) | C++14 | 2000 ms | 20788 KB |
// Sous-tâche 1 & 2 #include <algorithm> #include <iostream> #include <cstdio> #include <array> using namespace std; const int oo = 1000*1000*1000; const int INCONNU = -1; const int TAILLE_MAX = 40; const int NB_MAX_LIGNES = TAILLE_MAX; const int NB_MAX_COLONNES = TAILLE_MAX; const int NB_DIRECTIONS = 4; const int DELTAS_DIRECTIONS[NB_DIRECTIONS][2] = { {0, 1}, {1, 0}, {0, -1}, {-1, 0} }; int nbLignes, nbColonnes; int dynamique[TAILLE_MAX][TAILLE_MAX][TAILLE_MAX][TAILLE_MAX]; int getNbActionsMin (const array<array<bool, NB_MAX_COLONNES>, NB_MAX_LIGNES> &estPlein, const array<int, NB_DIRECTIONS> &nbUtilisations) { int &res = dynamique[ nbUtilisations[0] ][ nbUtilisations[1] ][ nbUtilisations[2] ][ nbUtilisations[3] ]; if (res != INCONNU) { return res; } bool estValide = true; for (int iLigne=0; iLigne<nbLignes; iLigne++) { for (int iColonne=0; iColonne<nbColonnes; iColonne++) { if (!estPlein[iLigne][iColonne]) { estValide = false; } } } if (estValide) { return res = 0; } res = +oo; for (int iDirection=0; iDirection<NB_DIRECTIONS; iDirection++) { auto nouveauEstPlein = estPlein; for (int iLigne=0; iLigne<nbLignes; iLigne++) { for (int iColonne=0; iColonne<nbColonnes; iColonne++) { if (!estPlein[iLigne][iColonne]) { continue; } const int iNouvelleLigne = iLigne + DELTAS_DIRECTIONS[iDirection][0]; const int iNouvelleColonne = iColonne + DELTAS_DIRECTIONS[iDirection][1]; if (iNouvelleLigne < 0 || iNouvelleLigne >= nbLignes || iNouvelleColonne < 0 || iNouvelleColonne >= nbColonnes) { continue; } nouveauEstPlein[iNouvelleLigne][iNouvelleColonne] = true; } } if (nouveauEstPlein != estPlein) { auto nouveauNbUtilisations = nbUtilisations; nouveauNbUtilisations[iDirection]++; res = min(getNbActionsMin(nouveauEstPlein, nouveauNbUtilisations) + 1, res); } } return res; } int main () { fill(***dynamique, ***dynamique+TAILLE_MAX*TAILLE_MAX*TAILLE_MAX*TAILLE_MAX, INCONNU); scanf("%d %d", &nbLignes, &nbColonnes); if (nbLignes > NB_MAX_LIGNES || nbColonnes > NB_MAX_COLONNES) { printf("%d\n", 1/0); return 0; } array<array<bool, NB_MAX_COLONNES>, NB_MAX_LIGNES> estPlein; for (int iLigne=0; iLigne<nbLignes; iLigne++) { for (int iColonne=0; iColonne<nbColonnes; iColonne++) { estPlein[iLigne][iColonne] = false; } } int nbCellulesPleines; scanf("%d", &nbCellulesPleines); for (int iCellule=0; iCellule<nbCellulesPleines; iCellule++) { int iLigne, iColonne; scanf("%d %d", &iLigne, &iColonne); iLigne--, iColonne--; estPlein[iLigne][iColonne] = true; } printf("%d\n", getNbActionsMin(estPlein, {0, 0, 0, 0})); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 10360 KB | Output is correct |
2 | Correct | 10 ms | 10468 KB | Output is correct |
3 | Correct | 10 ms | 10468 KB | Output is correct |
4 | Correct | 10 ms | 10588 KB | Output is correct |
5 | Correct | 10 ms | 10588 KB | Output is correct |
6 | Correct | 10 ms | 10588 KB | Output is correct |
7 | Correct | 10 ms | 10596 KB | Output is correct |
8 | Correct | 10 ms | 10600 KB | Output is correct |
9 | Correct | 11 ms | 10600 KB | Output is correct |
10 | Correct | 10 ms | 10600 KB | Output is correct |
11 | Correct | 10 ms | 10600 KB | Output is correct |
12 | Correct | 12 ms | 10600 KB | Output is correct |
13 | Correct | 12 ms | 10600 KB | Output is correct |
14 | Correct | 11 ms | 10600 KB | Output is correct |
15 | Correct | 11 ms | 10600 KB | Output is correct |
16 | Correct | 11 ms | 10600 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 10360 KB | Output is correct |
2 | Correct | 10 ms | 10468 KB | Output is correct |
3 | Correct | 10 ms | 10468 KB | Output is correct |
4 | Correct | 10 ms | 10588 KB | Output is correct |
5 | Correct | 10 ms | 10588 KB | Output is correct |
6 | Correct | 10 ms | 10588 KB | Output is correct |
7 | Correct | 10 ms | 10596 KB | Output is correct |
8 | Correct | 10 ms | 10600 KB | Output is correct |
9 | Correct | 11 ms | 10600 KB | Output is correct |
10 | Correct | 10 ms | 10600 KB | Output is correct |
11 | Correct | 10 ms | 10600 KB | Output is correct |
12 | Correct | 12 ms | 10600 KB | Output is correct |
13 | Correct | 12 ms | 10600 KB | Output is correct |
14 | Correct | 11 ms | 10600 KB | Output is correct |
15 | Correct | 11 ms | 10600 KB | Output is correct |
16 | Correct | 11 ms | 10600 KB | Output is correct |
17 | Correct | 51 ms | 10600 KB | Output is correct |
18 | Correct | 279 ms | 10980 KB | Output is correct |
19 | Execution timed out | 2045 ms | 10980 KB | Time limit exceeded |
20 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 10360 KB | Output is correct |
2 | Correct | 10 ms | 10468 KB | Output is correct |
3 | Correct | 10 ms | 10468 KB | Output is correct |
4 | Correct | 10 ms | 10588 KB | Output is correct |
5 | Correct | 10 ms | 10588 KB | Output is correct |
6 | Correct | 10 ms | 10588 KB | Output is correct |
7 | Correct | 10 ms | 10596 KB | Output is correct |
8 | Correct | 10 ms | 10600 KB | Output is correct |
9 | Correct | 11 ms | 10600 KB | Output is correct |
10 | Correct | 10 ms | 10600 KB | Output is correct |
11 | Correct | 10 ms | 10600 KB | Output is correct |
12 | Correct | 12 ms | 10600 KB | Output is correct |
13 | Correct | 12 ms | 10600 KB | Output is correct |
14 | Correct | 11 ms | 10600 KB | Output is correct |
15 | Correct | 11 ms | 10600 KB | Output is correct |
16 | Correct | 11 ms | 10600 KB | Output is correct |
17 | Correct | 51 ms | 10600 KB | Output is correct |
18 | Correct | 279 ms | 10980 KB | Output is correct |
19 | Execution timed out | 2045 ms | 10980 KB | Time limit exceeded |
20 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 20 ms | 20788 KB | Execution killed with signal 4 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 20 ms | 20788 KB | Execution killed with signal 4 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 10360 KB | Output is correct |
2 | Correct | 10 ms | 10468 KB | Output is correct |
3 | Correct | 10 ms | 10468 KB | Output is correct |
4 | Correct | 10 ms | 10588 KB | Output is correct |
5 | Correct | 10 ms | 10588 KB | Output is correct |
6 | Correct | 10 ms | 10588 KB | Output is correct |
7 | Correct | 10 ms | 10596 KB | Output is correct |
8 | Correct | 10 ms | 10600 KB | Output is correct |
9 | Correct | 11 ms | 10600 KB | Output is correct |
10 | Correct | 10 ms | 10600 KB | Output is correct |
11 | Correct | 10 ms | 10600 KB | Output is correct |
12 | Correct | 12 ms | 10600 KB | Output is correct |
13 | Correct | 12 ms | 10600 KB | Output is correct |
14 | Correct | 11 ms | 10600 KB | Output is correct |
15 | Correct | 11 ms | 10600 KB | Output is correct |
16 | Correct | 11 ms | 10600 KB | Output is correct |
17 | Correct | 51 ms | 10600 KB | Output is correct |
18 | Correct | 279 ms | 10980 KB | Output is correct |
19 | Execution timed out | 2045 ms | 10980 KB | Time limit exceeded |
20 | Halted | 0 ms | 0 KB | - |