이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(a, b) for(int a = 0; a < (int)(b); a++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=1e5+10;
int dp[N][4][4][4][4];
string s;
//M=0,F=1,B=2
void ob(int k){
int num=(s[k]=='M'?0:(s[k]=='F'?1:2));
rep(i,4) rep(j,4) rep(x,4) rep(y,4){
bool c[4];
c[0]=0,c[1]=0,c[2]=0,c[3]=0;
c[i]=1,c[j]=1,c[num]=1;
int diff1=c[0]+c[1]+c[2];
c[i]=0,c[j]=0,c[num]=0,c[num]=1,c[x]=1,c[y]=1;
int diff2=c[0]+c[1]+c[2];
dp[k][i][j][x][y]=max(dp[k+1][num][i][x][y]+diff1,dp[k+1][i][j][num][x]+diff2);
}
}
void solve(){
int n;
cin>>n;
cin>>s;
for(int i=s.size()-1;i>=0;i--) ob(i);
int res=0;
cout<<dp[0][3][3][3][3]<<"\n";
}
int main(){
ios_base::sync_with_stdio(0),cin.tie(0);
solve();
}
컴파일 시 표준 에러 (stderr) 메시지
miners.cpp: In function 'void solve()':
miners.cpp:30:6: warning: unused variable 'res' [-Wunused-variable]
30 | int res=0;
| ^~~
# | 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... |