제출 #346424

#제출 시각아이디문제언어결과실행 시간메모리
346424dgqMiners (IOI07_miners)C++17
100 / 100
316 ms896 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e5; int food[N + 1], dp[2][4][4][4][4]; char str[N + 1]; int nFood; int score(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 = score(x1, x2, food[i]) + dp[next][food[i]][x1][y1][y2]; int send_to_mine2 = score(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:27:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   27 |   scanf("%d", &nFood);
      |   ~~~~~^~~~~~~~~~~~~~
miners.cpp:28:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   28 |   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...