結果
問題 | No.2738 CPC To F |
ユーザー | N-noa21 |
提出日時 | 2024-04-20 11:14:10 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,130 bytes |
コンパイル時間 | 2,244 ms |
コンパイル使用メモリ | 206,392 KB |
実行使用メモリ | 46,776 KB |
最終ジャッジ日時 | 2024-10-12 06:53:16 |
合計ジャッジ時間 | 3,407 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,820 KB |
testcase_01 | AC | 2 ms
6,816 KB |
testcase_02 | AC | 72 ms
46,776 KB |
testcase_03 | AC | 73 ms
46,676 KB |
testcase_04 | AC | 2 ms
6,820 KB |
testcase_05 | AC | 2 ms
6,816 KB |
testcase_06 | AC | 2 ms
6,816 KB |
testcase_07 | AC | 2 ms
6,816 KB |
testcase_08 | WA | - |
testcase_09 | AC | 8 ms
6,820 KB |
testcase_10 | AC | 2 ms
6,816 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 9 ms
7,424 KB |
testcase_15 | AC | 9 ms
7,296 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 10 ms
7,552 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; using uint = unsigned; using pii = pair<int, int>; using pll = pair<ll, ll>; template<class T> using pq = priority_queue<T, vector<T>, greater<T>>; const ll LINF=0x1fffffffffffffff; const ll MINF=0x7fffffffffff; const int INF=0x3fffffff; const int MOD=1000000007; const int MOD2=998244353; const ld EPS=1e-9; const ld PI=3.14159265358979323846; const ll dx[] = {0, 1, 0, -1, 1, -1, 1, -1}; const ll dy[] = {1, 0, -1, 0, 1, 1, -1, -1}; #define all(x) (x).begin(), (x).end() #define pb push_back #define eb emplace_back #define mp make_pair #define fi first #define se second #define rep(i, n) rep2(i, 0, n) #define rep2(i, m, n) for (int i = m; i < (n); i++) #define per(i, b) per2(i, 0, b) #define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--) #define ALL(c) (c).begin(), (c).end() #define SZ(x) ((int)(x).size()) #define nep(x) next_permutation(ALL(x)) template <class T> using V = vector<T>; template <class T> using VV = V<V<T>>; template <class T> using VVV = V<VV<T>>; template <class T> using VVVV = V<VVV<T>>; template <class T> using V_p = V<pair<T,T>>; template <class T> using n_pq = priority_queue<T>; template <class T> using r_pq = priority_queue<T,vector<T>,greater<T>>; template <class T>ostream &operator<<(ostream &o,const vector<T>&v) {o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;} template <class T>ostream &operator<<(ostream &o,const deque<T>&v) {o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;} template <class T>ostream &operator<<(ostream &o,const set<T>&v) {o<<"{";for(auto i:v)o<<" "<<i;o<<"}";return o;} ll pow_ll(ll x, ll n) { long long ret = 1; while (n > 0) { if (n & 1) ret *= x; // n の最下位bitが 1 ならば x^(2^i) をかける x *= x; n >>= 1; // n を1bit 左にずらす } return ret; } //////////////////////////////////////////////////// int main() { ll N; cin >> N; string S; cin >> S; VV<ll> dp(N+1,V<ll>(6,-1)); dp[0][0] = 0; ll max_case; max_case = 0; rep(i,N) { if (S[i] == 'C') { dp[i+1][1] = max_case; if (dp[i][2] >= 0) { dp[i+1][3] = max(dp[i+1][3],dp[i][2]); } } else if (S[i] == 'P') { if (dp[i][1] >= 0) { dp[i+1][2] = max(dp[i+1][2],dp[i][1]); } } else if (S[i] == 'T') { if (dp[i][3] >= 0) { dp[i+1][4] = max(dp[i+1][4],dp[i][3]); } } else if (S[i] == 'F') { if (dp[i][4]>=0) { dp[i+1][0] = max(dp[i+1][0],dp[i][4]+1); max_case = max(max_case,dp[i+1][0]); } } if (S.substr(i,3) == "CPC") { if (dp[i][4] >= 0 and i+3<=N) { dp[i+3][0] = max(dp[i+3][0],dp[i][4]+1); max_case = max(max_case,dp[i+3][0]); } } } cout << max_case << endl; }