結果

問題 No.161 制限ジャンケン
ユーザー odan3240odan3240
提出日時 2015-12-27 14:40:15
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,525 bytes
コンパイル時間 871 ms
コンパイル使用メモリ 96,184 KB
実行使用メモリ 412,416 KB
最終ジャッジ日時 2023-10-19 11:14:32
合計ジャッジ時間 3,903 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef long long ll;

int calc(char c1,char c2) {
    if(c1==c2) return 1;
    if(c1=='G'&&c2=='P') return 3;
    if(c1=='P'&&c2=='C') return 3;
    if(c1=='C'&&c2=='G') return 3;
    return 0;
}

int G,C,P;
string S;
using Vector=vector<unsigned char>;
using Matrix=vector<Vector>;
vector<Matrix> dp[301];
int dfs(int idx,int g,int c,int p) {
    if(idx==S.size()) return 0;
    int ret = 0;
    if(dp[idx][g][c][p]!=-1) return dp[idx][g][c][p];
    if(g!=0) ret = max(dfs(idx+1,g-1,c,p)+calc(S[idx],'G'), ret);
    if(c!=0) ret = max(dfs(idx+1,g,c-1,p)+calc(S[idx],'C'), ret);
    if(p!=0) ret = max(dfs(idx+1,g,c,p-1)+calc(S[idx],'P'), ret);

    return dp[idx][g][c][p]=ret;
}
int main() {
    cin>>G>>C>>P;
    rep(i,301) dp[i]=vector<Matrix>(G+1,Matrix(C+1,Vector(P+1,-1)));
    //rep(i,301) rep(j,dp[i].size()) rep(k,dp[i][j].size()) for(auto &e:dp[i][j][k]) e=-1;
    cin>>S;

    cout<<dfs(0,G,C,P)<<endl;

    return 0;
}
0