제출 #383999

#제출 시각아이디문제언어결과실행 시간메모리
383999iulia13Miners (IOI07_miners)C++14
0 / 100
2 ms512 KiB
#include <fstream> #include <algorithm> using namespace std; ifstream cin ("miners.in"); ofstream cout ("miners.out"); const int nmax = 1e5 + 5; const int mskmax = 16; const int b = 4; char s[nmax]; int dp[2][mskmax][mskmax]; ///M = 1, F = 2, B = 3 ///nmc = 0 int cod[30]; int value[80]; void maxim(int &a, int b) { a = max(a, b); } int v[3]; int main() { int n, i, j; cin >> n; cin >> s + 1; cod['M' - 'A'] = 1; cod['F' - 'A'] = 2; cod['B' - 'A'] = 3; for (i = 0; i < mskmax * b; i++) { if (i == 63) i = 63; v[0] = i % b; v[1] = (i / b) % b; v[2] = i / (b * b); sort (v, v + 3); if (v[2] == 0) continue; if (v[1] == 0) { value[i] = 1; continue; } if (v[0] == 0) { if (v[1] == v[2]) value[i] = 1; else value[i] = 2; continue; } if (!v[0]) continue; if (v[0] == v[2]) value[i] = 1; else if (v[0] != v[1] && v[2] != v[1]) value[i] = 3; else value[i] = 2; } int val = cod[s[1] - 'A']; for (i = 0; i <= 1; i++) for (int msk1 = 0; msk1 < mskmax; msk1++) for (int msk2 = 0; msk2 < mskmax; msk2++) dp[i][msk1][msk2] = -2e9; dp[0][0][0] = 0; int ans = 0; for (i = 1; i <= n; i++) { for (int msk1 = 0; msk1 < mskmax; msk1++) for (int msk2 = 0; msk2 < mskmax; msk2++) dp[i % 2][msk1][msk2] = -2e9; for (int msk1 = 0; msk1 < mskmax; msk1++) for (int msk2 = 0; msk2 < mskmax; msk2++) { int val = cod[s[i] - 'A']; int msk11 = (msk1 % b) * b + val; int msk22 = (msk2 % b) * b + val; ///bag in primul maxim(dp[i % 2][msk11][msk2], dp[1 - i % 2][msk1][msk2] + value[msk1 + b * b * val]); maxim(dp[i % 2][msk1][msk22], dp[1 - i % 2][msk1][msk2] + value[msk2 + b * b * val]); if (i == n) { maxim(ans, dp[i % 2][msk11][msk2]); maxim(ans, dp[i % 2][msk1][msk22]); } } } cout << ans; return 0; }

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

miners.cpp: In function 'int main()':
miners.cpp:24:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   24 |     cin >> s + 1;
      |            ~~^~~
miners.cpp:22:15: warning: unused variable 'j' [-Wunused-variable]
   22 |     int n, i, j;
      |               ^
miners.cpp:61:9: warning: unused variable 'val' [-Wunused-variable]
   61 |     int val = cod[s[1] - '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...