이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10,M=2e5+100,OO=0x3f3f3f3f,mod=1e8;
int dp[N][4][4][4][4],n;
string s;
int diff(int x, int y, int z){
set <int> ret = {x, y, z};
while(*ret.rbegin() == 3){
ret.erase(--ret.end());
}
return ret.size();
}
int id(char c){
if(c=='M') return 0;
if(c=='B') return 1;
if(c=='F') return 2;
}
int solve(int i,int pl1,int pl2,int pr1,int pr2){
if(i==n) return 0;
int& ret=dp[i][pl1][pl2][pr1][pr2];
if(~ret) return ret;
int op1=diff(pl1,pl2,id(s[i]))+solve(i+1,pl2,id(s[i]),pr1,pr2);
int op2=diff(id(s[i]),pr1,pr2)+solve(i+1,pl1,pl2,pr2,id(s[i]));
return ret=max(op1,op2);
}
int main(){
cin>>n>>s;
memset(dp,-1,sizeof(dp));
cout<<solve(0,3,3,3,3);
}
컴파일 시 표준 에러 (stderr) 메시지
miners.cpp: In function 'int id(char)':
miners.cpp:18:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# | 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... |