이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,id=numeric_limits<int>::lowest(); cin >> n; string s; cin >> s; vector dp(4,vector(4,vector(4,vector<int>(4,id))));
string u = "MFB"; dp[3][3][3][3] = 0; auto res = dp;
for (char a:s){
int t = find(u.begin(),u.end(),a)-u.begin();
for (int i(0);i < 4;++i) for (int k(0);k < 4;++k) for (int j(0);j < 4;++j) for (int l(0);l < 4;++l){
if (dp[i][k][j][l]!=id){
res[k][t][j][l] = max(res[k][t][j][l],dp[i][k][j][l]+(i==0||k==0||t==0)+(i==1||k==1||t==1)+(i==2||k==2||t==2));
res[i][k][l][t] = max(res[i][k][l][t],dp[i][k][j][l]+(j==0||l==0||t==0)+(j==1||l==1||t==1)+(j==2||l==2||t==2));
}
}
swap(dp,res);
}
int r = 0;
for (int i(0);i < 4;++i) for (int k(0);k < 4;++k) for (int j(0);j < 4;++j) for (int l(0);l < 4;++l){
r = max(r,dp[i][k][j][l]);
}
cout << r << endl;
}
# | 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... |