제출 #292126

#제출 시각아이디문제언어결과실행 시간메모리
292126KastandaMiners (IOI07_miners)C++11
100 / 100
177 ms512 KiB
// M #include<bits/stdc++.h> using namespace std; const int N = 100005; int n, dp[4][4][4][4], dpt[4][4][4][4]; char A[N]; int main() { scanf("%d%s", &n, A); for (int i = 0; i < n; i ++) { if (A[i] == 'M') A[i] = 1; if (A[i] == 'B') A[i] = 2; if (A[i] == 'F') A[i] = 3; } auto Get = [](int a, int b, int c){ int C[4] = {0, 0, 0, 0}; C[a] = C[b] = C[c] = 1; return C[1] + C[2] + C[3]; }; memset(dp, -63, sizeof(dp)); dp[0][0][0][0] = 0; for (int i = 0; i < n; i ++) { memset(dpt, -63, sizeof(dpt)); for (int a = 0; a < 4; a ++) for (int b = 0; b < 4; b ++) for (int c = 0; c < 4; c ++) for (int d = 0; d < 4; d ++) { dpt[a][b][d][A[i]] = max(dpt[a][b][d][A[i]], dp[a][b][c][d] + Get(c, d, A[i])); dpt[b][A[i]][c][d] = max(dpt[b][A[i]][c][d], dp[a][b][c][d] + Get(a, b, A[i])); } memcpy(dp, dpt, sizeof(dp)); } int Mx = 0; for (int a = 0; a < 4; a ++) for (int b = 0; b < 4; b ++) for (int c = 0; c < 4; c ++) for (int d = 0; d < 4; d ++) Mx = max(Mx, dp[a][b][c][d]); return !printf("%d\n", Mx); }

컴파일 시 표준 에러 (stderr) 메시지

miners.cpp: In function 'int main()':
miners.cpp:33:65: warning: array subscript has type 'char' [-Wchar-subscripts]
   33 |                                                 dpt[a][b][d][A[i]] = max(dpt[a][b][d][A[i]], dp[a][b][c][d] + Get(c, d, A[i]));
      |                                                              ~~~^
miners.cpp:33:90: warning: array subscript has type 'char' [-Wchar-subscripts]
   33 |                                                 dpt[a][b][d][A[i]] = max(dpt[a][b][d][A[i]], dp[a][b][c][d] + Get(c, d, A[i]));
      |                                                                                       ~~~^
miners.cpp:34:59: warning: array subscript has type 'char' [-Wchar-subscripts]
   34 |                                                 dpt[b][A[i]][c][d] = max(dpt[b][A[i]][c][d], dp[a][b][c][d] + Get(a, b, A[i]));
      |                                                        ~~~^
miners.cpp:34:84: warning: array subscript has type 'char' [-Wchar-subscripts]
   34 |                                                 dpt[b][A[i]][c][d] = max(dpt[b][A[i]][c][d], dp[a][b][c][d] + Get(a, b, A[i]));
      |                                                                                 ~~~^
miners.cpp:9:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |         scanf("%d%s", &n, A);
      |         ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...