結果

問題 No.1405 ジグザグロボット
ユーザー SSRSSSRS
提出日時 2020-12-11 22:13:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,184 bytes
コンパイル時間 1,996 ms
コンパイル使用メモリ 179,524 KB
実行使用メモリ 40,084 KB
最終ジャッジ日時 2023-10-16 23:48:54
合計ジャッジ時間 28,176 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
4,348 KB
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 AC 275 ms
6,420 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 291 ms
6,480 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 312 ms
6,704 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 WA -
testcase_34 WA -
testcase_35 TLE -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000;
int main(){
  int N, X, Y;
  cin >> N >> X >> Y;
  string S;
  cin >> S;
  vector<string> T(1);
  for (int i = 0; i < N; i++){
    if (S[i] == 'S'){
      T.push_back("");
    } else {
      T.back() += S[i];
    }
  }
  int M = T.size();
  if (Y >= M){
    cout << -1 << endl;
  } else {
    vector<vector<int>> a(M + 1, vector<int>(M + 1, 0));
    for (int i = 0; i < M; i++){
      for (int j = i + 1; j <= M; j++){
        for (int k = i; k < j; k++){
          int sz = T[k].size();
          for (int l = 0; l < sz; l++){
            if (T[k][l] == 'L'){
              a[i][j]--;
            } else {
              a[i][j]++;
            }
            a[i][j] = max(a[i][j], 0);
          }
        }
      }
    }
    vector<vector<int>> dp(Y + 2, vector<int>(M + 1, -INF));
    dp[0][0] = 0;
    for (int i = 0; i <= Y; i++){
      for (int j = 0; j < M; j++){
        for (int k = j + 1; k < M; k++){
          dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + a[j][k]);
        }
      }
    }
    if (dp[Y + 1][M] < X){
      cout << -1 << endl;
    } else {
      //YES
      //DP復元を書く
    }
  }
}
0