結果
問題 | No.161 制限ジャンケン |
ユーザー |
![]() |
提出日時 | 2018-08-12 21:03:52 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 32 ms / 5,000 ms |
コード長 | 1,192 bytes |
コンパイル時間 | 1,748 ms |
コンパイル使用メモリ | 166,964 KB |
実行使用メモリ | 7,680 KB |
最終ジャッジ日時 | 2024-09-24 07:33:39 |
合計ジャッジ時間 | 2,297 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
#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;}