結果

問題 No.161 制限ジャンケン
ユーザー PulmnPulmn
提出日時 2018-08-12 21:03:52
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 23 ms / 5,000 ms
コード長 1,192 bytes
コンパイル時間 1,905 ms
コンパイル使用メモリ 167,344 KB
実行使用メモリ 7,840 KB
最終ジャッジ日時 2023-10-24 16:23:30
合計ジャッジ時間 2,556 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 23 ms
7,840 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 23 ms
7,840 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 4 ms
4,348 KB
testcase_11 AC 3 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 16 ms
6,424 KB
testcase_14 AC 4 ms
4,348 KB
testcase_15 AC 7 ms
4,840 KB
testcase_16 AC 3 ms
4,348 KB
testcase_17 AC 3 ms
4,348 KB
testcase_18 AC 3 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e6+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int A,B,C;
string s;
vector<vvi> dp;

int f(int x,char c){
	int y=0;
	if(c=='C') y=1;
	if(c=='P') y=2;
	if(x==y) return 1;
	if((x+1)%3==y) return 3;
	return 0;
}

int Rec(int x,int y,int z){
	if(dp[x][y][z]!=-1) return dp[x][y][z];
	int res=0,I=A+B+C-x-y-z;
	if(x) res=max(res,Rec(x-1,y,z)+f(0,s[I]));
	if(y) res=max(res,Rec(x,y-1,z)+f(1,s[I]));
	if(z) res=max(res,Rec(x,y,z-1)+f(2,s[I]));
	return dp[x][y][z]=res;
}

int main(){
	cin>>A>>B>>C>>s;
	dp=vector<vvi>(A+1,vvi(B+1,vi(C+1,-1)));
	cout<<Rec(A,B,C)<<endl;
}
0