제출 #346725

#제출 시각아이디문제언어결과실행 시간메모리
346725BlancaHMMiners (IOI07_miners)C++14
100 / 100
317 ms1004 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e5; int food[N + 1]; // Dimensiones: n, penultima comida mina 1, ultima comida mina1, // penultima comida mina 2, ultima comida mina2 int dp[2][4][4][4][4]; char str[N + 1]; int nFood; int value(int a, int b, int c) { int ans = 0; if (a == 1 || b == 1 || c == 1) { ++ans; } if (a == 2 || b == 2 || c == 2) { ++ans; } if (a == 3 || b == 3 || c == 3) { ++ans; } return ans; } int main() { scanf("%d", &nFood); scanf(" %s", str); for (int i = 1; i <= nFood; ++i) { char foodchar = str[i - 1]; switch(foodchar) { case 'M': food[i] = 1; break; case 'F': food[i] = 2; break; case 'B': food[i] = 3; break; } } for (int i = nFood + 1; i >= 1; --i) { for (int x1 = 0; x1 <= 3; ++x1) { for (int x2 = 0; x2 <= 3; ++x2) { for (int y1 = 0; y1 <= 3; ++y1) { for (int y2 = 0; y2 <= 3; ++y2) { int curr = i % 2; int next = curr ^ 1; if (i == nFood + 1) { dp[curr][x1][x2][y1][y2] = 0; } else { int send_to_mine1 = value(x1, x2, food[i]) + dp[next][food[i]][x1][y1][y2]; int send_to_mine2 = value(y1, y2, food[i]) + dp[next][x1][x2][food[i]][y1]; dp[curr][x1][x2][y1][y2] = max(send_to_mine1, send_to_mine2); } } } } } } cout << dp[1][0][0][0][0]; return 0; }

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

miners.cpp: In function 'int main()':
miners.cpp:30:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   30 |   scanf("%d", &nFood);
      |   ~~~~~^~~~~~~~~~~~~~
miners.cpp:31:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   31 |   scanf(" %s", str);
      |   ~~~~~^~~~~~~~~~~~
#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...