이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
#define all(a) begin(a), end(a)
#define each(i,a) for(auto&& i : a)
#define overload3(_1, _2, _3, name, ...) name
#define rep1(n) for(int i = 0; i < (n); ++i)
#define rep2(i, n) for(int i = 0; i < (n); ++i)
#define rep3(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__)
template<class T, class U> bool chmax(T& a, const U& b){ if(a < b){ a = b; return 1; } return 0; }
inline constexpr int kinds(int a, int b, int c){
int ans = 0;
rep(i, 1, 4) if(a == i || b == i || c == i) ans++;
return ans;
}
int main(){
string s;
cin >> s >> s;
each(i, s){
if(i == 'B') i = 1;
else if(i == 'F') i = 2;
else i = 3;
}
int dp[2][4][4][4][4];
memset(dp[0], 0x80, sizeof(dp[0]));
dp[0][0][0][0][0] = 0;
int from = 0, to = 1;
each(c, s){
memset(dp[to], 0x80, sizeof(dp[to]));
rep(a1, 4) rep(a2, 4) rep(b1, 4) rep(b2, 4){
chmax(dp[to][a2][c][b1][b2], dp[from][a1][a2][b1][b2] + kinds(a1, a2, c));
chmax(dp[to][a1][a2][b2][c], dp[from][a1][a2][b1][b2] + kinds(b1, b2, c));
}
from ^= 1;
to ^= 1;
}
cout << *max_element(dp[from][0][0][0], dp[from][4][0][0]) << endl;
}
컴파일 시 표준 에러 (stderr) 메시지
miners.cpp: In function 'int main()':
miners.cpp:33:31: warning: array subscript has type 'char' [-Wchar-subscripts]
chmax(dp[to][a2][c][b1][b2], dp[from][a1][a2][b1][b2] + kinds(a1, a2, c));
^
miners.cpp:34:39: warning: array subscript has type 'char' [-Wchar-subscripts]
chmax(dp[to][a1][a2][b2][c], dp[from][a1][a2][b1][b2] + kinds(b1, b2, c));
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |