# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
68265 | 2018-08-16T10:30:28 Z | AdrienVannson | Cultivation (JOI17_cultivation) | C++14 | 3 ms | 552 KB |
// Sous-tâche 1 #include <algorithm> #include <iostream> #include <cstdio> #include <array> using namespace std; const int oo = 1000*1000*1000; const int NB_MAX_LIGNES = 4; const int NB_MAX_COLONNES = 4; const int NB_DIRECTIONS = 4; const int DELTAS_DIRECTIONS[NB_DIRECTIONS][2] = { {0, 1}, {1, 0}, {0, -1}, {-1, 0} }; int nbLignes, nbColonnes; int getNbActionsMin (const array<array<bool, NB_MAX_COLONNES>, NB_MAX_LIGNES> &estPlein) { 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 0; } int 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) { res = min(getNbActionsMin(nouveauEstPlein) + 1, res); } } return res; } int main () { 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); estPlein[iLigne][iColonne] = true; } printf("%d\n", getNbActionsMin(estPlein)); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 248 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 248 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 248 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 552 KB | Execution killed with signal 4 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 552 KB | Execution killed with signal 4 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 248 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |