Submission #46985644
Source Code Expand
#include <bits/stdc++.h> #ifdef LOCAL #include "debug.h" #else #define debug(...) #endif using int64 = long long; using uint = unsigned int; using uint64 = unsigned long long; bool ckmin(auto& a, auto b) { return b < a ? a = b, 1 : 0; } bool ckmax(auto& a, auto b) { return b > a ? a = b, 1 : 0; } using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); string s; int k; cin >> s >> k; int n = s.length(); vector dp(n + 1, vector<int>(n)); for (int i = 0; i < n; i++) { for (int j = i; j < n; j++) dp[i][j] = j - i + 1; } for (int len = 2; len <= n; len++) { for (int l = 0; l < n; l++) { int r = l + len - 1; if (r >= n) break; for (int t = l + 1; t <= r; t++) { ckmin(dp[l][r], dp[l][t - 1] + dp[t][r]); } if (s[l] == 'o') { for (int t = l + 1; t <= r; t++) { if (s[t] == 'f' && dp[l + 1][t - 1] == 0) { ckmin(dp[l][r], max(0, dp[t + 1][r] - k)); } } } } } cout << dp[0][n - 1] << '\n'; return 0; }
Submission Info
Submission Time | |
---|---|
Task | G - offence |
User | xindubawukong |
Language | C++ 20 (gcc 12.2) |
Score | 575 |
Code Size | 1106 Byte |
Status | AC |
Exec Time | 8 ms |
Memory | 3668 KiB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 575 / 575 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample00.txt, sample01.txt, sample02.txt, sample03.txt |
All | sample00.txt, sample01.txt, sample02.txt, sample03.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt, testcase20.txt, testcase21.txt, testcase22.txt, testcase23.txt, testcase24.txt, testcase25.txt, testcase26.txt, testcase27.txt, testcase28.txt, testcase29.txt, testcase30.txt, testcase31.txt, testcase32.txt, testcase33.txt, testcase34.txt, testcase35.txt, testcase36.txt, testcase37.txt, testcase38.txt, testcase39.txt, testcase40.txt, testcase41.txt, testcase42.txt, testcase43.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample00.txt | AC | 1 ms | 3444 KiB |
sample01.txt | AC | 1 ms | 3340 KiB |
sample02.txt | AC | 1 ms | 3416 KiB |
sample03.txt | AC | 1 ms | 3372 KiB |
testcase00.txt | AC | 1 ms | 3412 KiB |
testcase01.txt | AC | 1 ms | 3452 KiB |
testcase02.txt | AC | 1 ms | 3320 KiB |
testcase03.txt | AC | 1 ms | 3412 KiB |
testcase04.txt | AC | 1 ms | 3416 KiB |
testcase05.txt | AC | 1 ms | 3376 KiB |
testcase06.txt | AC | 1 ms | 3264 KiB |
testcase07.txt | AC | 1 ms | 3408 KiB |
testcase08.txt | AC | 1 ms | 3380 KiB |
testcase09.txt | AC | 6 ms | 3468 KiB |
testcase10.txt | AC | 4 ms | 3452 KiB |
testcase11.txt | AC | 4 ms | 3456 KiB |
testcase12.txt | AC | 6 ms | 3604 KiB |
testcase13.txt | AC | 8 ms | 3540 KiB |
testcase14.txt | AC | 6 ms | 3520 KiB |
testcase15.txt | AC | 7 ms | 3500 KiB |
testcase16.txt | AC | 6 ms | 3468 KiB |
testcase17.txt | AC | 7 ms | 3540 KiB |
testcase18.txt | AC | 6 ms | 3536 KiB |
testcase19.txt | AC | 7 ms | 3540 KiB |
testcase20.txt | AC | 5 ms | 3664 KiB |
testcase21.txt | AC | 7 ms | 3456 KiB |
testcase22.txt | AC | 6 ms | 3448 KiB |
testcase23.txt | AC | 7 ms | 3456 KiB |
testcase24.txt | AC | 6 ms | 3584 KiB |
testcase25.txt | AC | 8 ms | 3504 KiB |
testcase26.txt | AC | 6 ms | 3456 KiB |
testcase27.txt | AC | 8 ms | 3604 KiB |
testcase28.txt | AC | 7 ms | 3500 KiB |
testcase29.txt | AC | 7 ms | 3540 KiB |
testcase30.txt | AC | 7 ms | 3540 KiB |
testcase31.txt | AC | 7 ms | 3528 KiB |
testcase32.txt | AC | 5 ms | 3668 KiB |
testcase33.txt | AC | 6 ms | 3456 KiB |
testcase34.txt | AC | 5 ms | 3520 KiB |
testcase35.txt | AC | 6 ms | 3540 KiB |
testcase36.txt | AC | 6 ms | 3540 KiB |
testcase37.txt | AC | 7 ms | 3504 KiB |
testcase38.txt | AC | 7 ms | 3536 KiB |
testcase39.txt | AC | 7 ms | 3604 KiB |
testcase40.txt | AC | 5 ms | 3540 KiB |
testcase41.txt | AC | 6 ms | 3576 KiB |
testcase42.txt | AC | 5 ms | 3396 KiB |
testcase43.txt | AC | 5 ms | 3516 KiB |