이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//fold
#ifndef KHALIL
#include <bits/stdc++.h>
#else
#include "header.h"
#endif
#define endl '\n'
#define mp make_pair
#define tostr(x) static_cast<ostringstream&>((ostringstream()<<dec<<x)).str()
#define rep(i,begin,end) for(auto i = begin;i < end;i++)
#define repr(i,begin,end) for(auto i = begin-1;i >= end;i--)
#define pb push_back
#define sz(a) ((int)(a).size())
#define fi first
#define se second
#define abs(a) ((a) < (0) ? (-1)*(a) : (a))
#define SQ(a) ((a)*(a))
#define eqd(a,b) (abs(a-b)<1e-9)
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename t> t in(t q){cin >> q;return q;}
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v){os << "[";for (int i = 0; i < sz(v); ++i) { os << v[i]; if (i != sz(v) - 1) os << ",";}os << "]";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const map<T, S>& v){for (auto it : v)os << "(" << it.first << ":" << it.second << ")";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const pair<T, S>& v){os << "(" << v.first << "," << v.second << ")";return os;}
const long double PI = acosl(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
inline int rand(int l,int r){return uniform_int_distribution<int>(l, r)(rng);}
inline ll rand(ll l,ll r){return uniform_int_distribution<ll>(l, r)(rng64);}
//endfold
#define N (100'005)
#define MOD (1000000000l + 7l)
#define OO (1050000000)
#define OOL (1100000000000000000)
//global
int dp[16][16][N];
int n;
string s;
char arr[N];
char getScore(char i,char c){
return __builtin_popcount(((1 << (i >> 2))|(1 << (i&3))|(1 << c))&14);
}
int solve(char m1,char m2,int done){
if(done == n) return 0;
if(dp[m1][m2][done] != -1) return dp[m1][m2][done];
dp[m1][m2][done] = max(solve(((m1<<2)|arr[done])&15,m2,done+1)+getScore(m1,arr[done]),
solve(m1,((m2<<2)|arr[done])&15,done+1)+getScore(m2,arr[done]));
return dp[m1][m2][done];
}
map<char,char> m = {{'M',1},{'B',2},{'F',3}};
int main(){
//fold
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cout << setprecision(10);
//endfold
memset(dp,-1,sizeof dp);
cin >> n >> s;
rep(i,0,n){
arr[i] = m[s[i]];
}
cout << solve(0,0,0);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
miners.cpp: In function 'int solve(char, char, int)':
miners.cpp:51:10: warning: array subscript has type 'char' [-Wchar-subscripts]
if(dp[m1][m2][done] != -1) return dp[m1][m2][done];
^
miners.cpp:51:14: warning: array subscript has type 'char' [-Wchar-subscripts]
if(dp[m1][m2][done] != -1) return dp[m1][m2][done];
^
miners.cpp:51:41: warning: array subscript has type 'char' [-Wchar-subscripts]
if(dp[m1][m2][done] != -1) return dp[m1][m2][done];
^
miners.cpp:51:45: warning: array subscript has type 'char' [-Wchar-subscripts]
if(dp[m1][m2][done] != -1) return dp[m1][m2][done];
^
miners.cpp:52:7: warning: array subscript has type 'char' [-Wchar-subscripts]
dp[m1][m2][done] = max(solve(((m1<<2)|arr[done])&15,m2,done+1)+getScore(m1,arr[done]),
^
miners.cpp:52:11: warning: array subscript has type 'char' [-Wchar-subscripts]
dp[m1][m2][done] = max(solve(((m1<<2)|arr[done])&15,m2,done+1)+getScore(m1,arr[done]),
^
miners.cpp:54:14: warning: array subscript has type 'char' [-Wchar-subscripts]
return dp[m1][m2][done];
^
miners.cpp:54:18: warning: array subscript has type 'char' [-Wchar-subscripts]
return dp[m1][m2][done];
^
# | 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... |