답안 #110135

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
110135 2019-05-09T14:17:15 Z Arturgo Dango Maker (JOI18_dango_maker) C++14
100 / 100
1119 ms 151516 KB
#include <iostream>
using namespace std;

string terrain[3000];

bool estPasse[3][3000][3000];
int dyn[3][3000][3000];

int nbLigs, nbCols;

bool estValide(int lig, int col) {
  return lig >= 0 && lig < nbLigs && col >= 0 && col < nbCols;
}

int maxLignes(int lig, int col, int peutBas) {
  if(lig <= -1 || col >= nbCols)
    return 0;
  
  if(estPasse[peutBas][lig][col])
    return dyn[peutBas][lig][col];
  estPasse[peutBas][lig][col] = true;

  bool valideBas = (peutBas == 0), valideDroite = true;

  if(terrain[lig][col] != 'R') {
    valideBas = false;
    valideDroite = false;
  }

  if(!estValide(lig + 1, col) || terrain[lig + 1][col] != 'G')
    valideBas = false;
  if(!estValide(lig + 2, col) || terrain[lig + 2][col] != 'W')
    valideBas = false;

  if(!estValide(lig, col + 1) || terrain[lig][col + 1] != 'G')
    valideDroite = false;
  if(!estValide(lig, col + 2) || terrain[lig][col + 2] != 'W')
    valideDroite = false;
  
  int maxi = maxLignes(lig - 1, col + 1, max(0, peutBas - 1)) + valideBas;

  if(valideDroite) {
    maxi = max(maxi, maxLignes(lig - 1, col + 1, 2) + 1);
  }
  
  dyn[peutBas][lig][col] = maxi;
  return maxi;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin >> nbLigs >> nbCols;

  for(int iLig = 0;iLig < nbLigs;iLig++) {
    cin >> terrain[iLig];
  }

  int totalLignes = 0;
  for(int iLig = 0;iLig < nbLigs;iLig++) {
    totalLignes += maxLignes(iLig, 0, 0);
  }

  for(int iCol = 1;iCol < nbCols;iCol++) {
    totalLignes += maxLignes(nbLigs - 1, iCol, 0);
  }

  cout << totalLignes << endl;
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 512 KB Output is correct
2 Correct 4 ms 512 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 3 ms 512 KB Output is correct
6 Correct 3 ms 512 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 3 ms 512 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 512 KB Output is correct
11 Correct 3 ms 512 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
13 Correct 3 ms 432 KB Output is correct
14 Correct 3 ms 512 KB Output is correct
15 Correct 3 ms 512 KB Output is correct
16 Correct 3 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 512 KB Output is correct
2 Correct 4 ms 512 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 3 ms 512 KB Output is correct
6 Correct 3 ms 512 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 3 ms 512 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 512 KB Output is correct
11 Correct 3 ms 512 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
13 Correct 3 ms 432 KB Output is correct
14 Correct 3 ms 512 KB Output is correct
15 Correct 3 ms 512 KB Output is correct
16 Correct 3 ms 512 KB Output is correct
17 Correct 2 ms 512 KB Output is correct
18 Correct 3 ms 512 KB Output is correct
19 Correct 2 ms 640 KB Output is correct
20 Correct 3 ms 640 KB Output is correct
21 Correct 3 ms 512 KB Output is correct
22 Correct 2 ms 640 KB Output is correct
23 Correct 2 ms 640 KB Output is correct
24 Correct 2 ms 512 KB Output is correct
25 Correct 2 ms 640 KB Output is correct
26 Correct 3 ms 384 KB Output is correct
27 Correct 2 ms 640 KB Output is correct
28 Correct 3 ms 640 KB Output is correct
29 Correct 3 ms 640 KB Output is correct
30 Correct 3 ms 512 KB Output is correct
31 Correct 3 ms 512 KB Output is correct
32 Correct 3 ms 512 KB Output is correct
33 Correct 3 ms 640 KB Output is correct
34 Correct 3 ms 640 KB Output is correct
35 Correct 2 ms 640 KB Output is correct
36 Correct 2 ms 640 KB Output is correct
37 Correct 2 ms 640 KB Output is correct
38 Correct 2 ms 640 KB Output is correct
39 Correct 3 ms 640 KB Output is correct
40 Correct 2 ms 640 KB Output is correct
41 Correct 2 ms 640 KB Output is correct
42 Correct 3 ms 640 KB Output is correct
43 Correct 3 ms 640 KB Output is correct
44 Correct 2 ms 652 KB Output is correct
45 Correct 3 ms 640 KB Output is correct
46 Correct 3 ms 640 KB Output is correct
47 Correct 2 ms 640 KB Output is correct
48 Correct 2 ms 640 KB Output is correct
49 Correct 3 ms 640 KB Output is correct
50 Correct 3 ms 640 KB Output is correct
51 Correct 3 ms 640 KB Output is correct
52 Correct 3 ms 640 KB Output is correct
53 Correct 3 ms 612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 512 KB Output is correct
2 Correct 4 ms 512 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 3 ms 512 KB Output is correct
6 Correct 3 ms 512 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 3 ms 512 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 512 KB Output is correct
11 Correct 3 ms 512 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
13 Correct 3 ms 432 KB Output is correct
14 Correct 3 ms 512 KB Output is correct
15 Correct 3 ms 512 KB Output is correct
16 Correct 3 ms 512 KB Output is correct
17 Correct 2 ms 512 KB Output is correct
18 Correct 3 ms 512 KB Output is correct
19 Correct 2 ms 640 KB Output is correct
20 Correct 3 ms 640 KB Output is correct
21 Correct 3 ms 512 KB Output is correct
22 Correct 2 ms 640 KB Output is correct
23 Correct 2 ms 640 KB Output is correct
24 Correct 2 ms 512 KB Output is correct
25 Correct 2 ms 640 KB Output is correct
26 Correct 3 ms 384 KB Output is correct
27 Correct 2 ms 640 KB Output is correct
28 Correct 3 ms 640 KB Output is correct
29 Correct 3 ms 640 KB Output is correct
30 Correct 3 ms 512 KB Output is correct
31 Correct 3 ms 512 KB Output is correct
32 Correct 3 ms 512 KB Output is correct
33 Correct 3 ms 640 KB Output is correct
34 Correct 3 ms 640 KB Output is correct
35 Correct 2 ms 640 KB Output is correct
36 Correct 2 ms 640 KB Output is correct
37 Correct 2 ms 640 KB Output is correct
38 Correct 2 ms 640 KB Output is correct
39 Correct 3 ms 640 KB Output is correct
40 Correct 2 ms 640 KB Output is correct
41 Correct 2 ms 640 KB Output is correct
42 Correct 3 ms 640 KB Output is correct
43 Correct 3 ms 640 KB Output is correct
44 Correct 2 ms 652 KB Output is correct
45 Correct 3 ms 640 KB Output is correct
46 Correct 3 ms 640 KB Output is correct
47 Correct 2 ms 640 KB Output is correct
48 Correct 2 ms 640 KB Output is correct
49 Correct 3 ms 640 KB Output is correct
50 Correct 3 ms 640 KB Output is correct
51 Correct 3 ms 640 KB Output is correct
52 Correct 3 ms 640 KB Output is correct
53 Correct 3 ms 612 KB Output is correct
54 Correct 3 ms 512 KB Output is correct
55 Correct 22 ms 21248 KB Output is correct
56 Correct 4 ms 768 KB Output is correct
57 Correct 33 ms 32504 KB Output is correct
58 Correct 92 ms 34732 KB Output is correct
59 Correct 780 ms 151292 KB Output is correct
60 Correct 655 ms 151460 KB Output is correct
61 Correct 749 ms 151340 KB Output is correct
62 Correct 2 ms 512 KB Output is correct
63 Correct 629 ms 150536 KB Output is correct
64 Correct 978 ms 151372 KB Output is correct
65 Correct 1059 ms 151516 KB Output is correct
66 Correct 1119 ms 151380 KB Output is correct
67 Correct 507 ms 63376 KB Output is correct
68 Correct 435 ms 63864 KB Output is correct
69 Correct 538 ms 95928 KB Output is correct
70 Correct 104 ms 35092 KB Output is correct
71 Correct 117 ms 35052 KB Output is correct
72 Correct 137 ms 35124 KB Output is correct
73 Correct 112 ms 35064 KB Output is correct
74 Correct 99 ms 35064 KB Output is correct
75 Correct 98 ms 35064 KB Output is correct
76 Correct 138 ms 35064 KB Output is correct
77 Correct 102 ms 35064 KB Output is correct
78 Correct 97 ms 35036 KB Output is correct
79 Correct 128 ms 35212 KB Output is correct
80 Correct 123 ms 35064 KB Output is correct
81 Correct 127 ms 35020 KB Output is correct
82 Correct 99 ms 35064 KB Output is correct
83 Correct 118 ms 35164 KB Output is correct
84 Correct 113 ms 35064 KB Output is correct
85 Correct 134 ms 35024 KB Output is correct
86 Correct 131 ms 35084 KB Output is correct
87 Correct 112 ms 35192 KB Output is correct
88 Correct 135 ms 35088 KB Output is correct
89 Correct 112 ms 35084 KB Output is correct
90 Correct 114 ms 35096 KB Output is correct