QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#185195 | #4190. Grid Delivery | rgnerdplayer# | WA | 16ms | 23240kb | C++20 | 1.1kb | 2023-09-21 18:40:55 | 2023-09-21 18:40:56 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
auto solve = [&]() {
int n, m;
cin >> n >> m;
vector<string> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
vector dp(n, vector<int>(m));
for (int i = 0; i < n; i++) {
for (int j = m - 1; j >= 0; j--) {
if (i == 0 && j == m - 1) {
dp[i][j] = a[i][j] == 'C';
continue;
}
if (i > 0 && j + 1 < m) {
dp[i][j] = max(dp[i][j], dp[i - 1][j + 1] + (a[i][j] == 'C'));
}
if (i > 0) {
dp[i][j] = max(dp[i][j], dp[i - 1][j]);
}
if (j + 1 < m) {
dp[i][j] = max(dp[i][j], dp[i][j + 1]);
}
}
}
cout << dp[n - 1][0] << '\n';
};
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3832kb
input:
4 4 __C_ C_C_ _C_C _CCC
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
4 6 CC____ _CCC__ ___C_C C__CCC
output:
2
result:
ok single line: '2'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
3 5 CC__C _C_CC CCCCC
output:
3
result:
ok single line: '3'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
4 4 __C_ CCCC ___C _C_C
output:
2
result:
ok single line: '2'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3484kb
input:
1 1 _
output:
0
result:
ok single line: '0'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3764kb
input:
1 1 C
output:
1
result:
ok single line: '1'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
10 10 __________ __________ __________ __________ __________ __________ __________ __________ __________ __________
output:
0
result:
ok single line: '0'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
10 10 _________C _________C _C__C_____ __________ ____C_____ _________C _______C__ __________ ______C___ _______C__
output:
3
result:
ok single line: '3'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
10 10 C_C__C____ ___C__C_CC _CCC___C__ __C_CCC__C __C_____CC _CCCCC_CCC C_C_CC_CCC ____C_C___ CC____CCCC C___C___C_
output:
7
result:
ok single line: '7'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
10 10 CCCCCCCCCC CCC_CC__CC CCCCCC_CCC _CCCCCC_CC CCCCCCCCCC C__CCCCCCC CCCCCCCC_C C_CCCCCCCC _CCCCCCCCC CCCCCCCCCC
output:
10
result:
ok single line: '10'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
10 10 CCCCCCCCCC CCCCCCCCCC CCCCCCCCCC CCCCCCCCCC CCCCCCCCC_ CCCCCCCCCC CCCCCCCCCC CCCCCCCCCC CCCCCCCCCC CCCCCCCCCC
output:
10
result:
ok single line: '10'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
100 100 ____________________________________________________________________________________________________ ____________________________________________________________________________________________________ __________________________________________________________________________________________...
output:
0
result:
ok single line: '0'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
100 100 __C_____________________C__________________C____C____________________________C______________________ ______________C__________C__C_C____C___CC___C_C_C__________C_____C____C____C________________CC____C_ ____C____________C_____________C_____C_C_________C____________________C_______C___________...
output:
44
result:
ok single line: '44'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
100 100 C_C_CCCC_C_CCC__C_CC_CC_C____CCC__CCCC__CCC_C__CC_CC_CCC__C___CCC_CCCC_CCC_________CCCCCCC_CC____C_C CC_C__CCC_CCC_CC_____CCC___C_CC____C_C__CC_C___C_CC___CCCC_C_C________C___C___CC_CC__CCC________C___ ___C_C_CC___CCC_______C_C___CCC_C_____C__CC_____CC_____C__CCC_C__CC_C_C_C_CC_C__C__C__C_CC...
output:
81
result:
ok single line: '81'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
100 100 CCCCC_CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC__CCCCCCCCC_CCCCCCCCCC_CCC_CCC_CCCCCCCCCCCCCCC_CCC_CCCC_CCCCCC CCCCCCCCCCCC_CCCCCCCCCCCCCCC_CCCCCCCCCCCC_CCCCCCCCCCCCCCCCCCCC__C__CCCCC_C__CCCCCCCC_CCC_CCCCCC_CCCC CCCCCCCCCCCCCCCC_CCC_CCC_CCCCCCC_CCCCC_CCCCC_CCCCC__CCCCCCCCCCCCCCCCCCCCCCCCC_CCCC_CC_CCCC...
output:
95
result:
ok single line: '95'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3912kb
input:
100 100 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC_CCCCCCCCCCCCCCCCCCC_CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC_CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...
output:
100
result:
ok single line: '100'
Test #17:
score: 0
Accepted
time: 15ms
memory: 23240kb
input:
2000 2000 __________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________...
output:
0
result:
ok single line: '0'
Test #18:
score: -100
Wrong Answer
time: 16ms
memory: 23160kb
input:
2000 2000 ___________CC________C__________C___C________C______C____________________________C___________C____C______C_C__________CC___C________________________________C____C_______________C___C__________C_C_______C_______C____C_C________C__C______________________C________C________________C________C__...
output:
944
result:
wrong answer 1st lines differ - expected: '945', found: '944'