이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int n,a[100010],i;
string s;
int val(vector<int> v){
set<int> s;
for(int x:v){
if(x) s.insert(x);
}
return s.size();
}
int rec(int idx,int a1,int a2,int b1,int b2){
if(idx==n) return 0;
int m1,m2;
m1=val({a1,a2,a[idx]});
m2=val({b1,b2,a[idx]});
return max(rec(idx+1,a[idx],a1,b1,b2)+m1,rec(idx+1,a1,a2,a[idx],b1)+m2);
}
int main(){
cin >> n >> s;
for(i=0;i<n;i++){
if(s[i]=='M') a[i]=1;
if(s[i]=='B') a[i]=2;
if(s[i]=='F') a[i]=3;
}
cout << rec(0,0,0,0,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... |