이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define li 100005
#define inf 1000000000
using namespace std;
int n,dp[li][4][4][4][4];
char s[li];
int solve(int a,int b,int c){
int tp[5]={};
tp[a]++;
tp[b]++;
tp[c]++;
int cev=0;
for(int i=1;i<=3;i++){
if(tp[i]>=1) cev++;
}
return cev;
}
int dfs(int node,int pre1,int pre2,int on1,int on2){
int cevap=-inf;
if(node==n+1) return 0;
if(~dp[node][pre1][pre2][on1][on2]) return dp[node][pre1][pre2][on1][on2];
int tut1=0;
if(s[node]=='B') tut1=1;
if(s[node]=='M') tut1=2;
if(s[node]=='F') tut1=3;
cevap=max(cevap,dfs(node+1,tut1,pre1,on1,on2)+solve(tut1,pre1,pre2));
cevap=max(cevap,dfs(node+1,pre1,pre2,tut1,on1)+solve(tut1,on1,on2));
return dp[node][pre1][pre2][on1][on2]=cevap;
}
int main(){
memset(dp,-1,sizeof(dp));
scanf("%d %s",&n,s+1);
int ty=dfs(1,0,0,0,0);
printf("%d\n",ty);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
miners.cpp: In function 'int main()':
miners.cpp:32:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %s",&n,s+1);
~~~~~^~~~~~~~~~~~~~~~
# | 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... |