QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#234508 | #4190. Grid Delivery | Fyind# | WA | 0ms | 3852kb | C++17 | 1.1kb | 2023-11-01 18:21:53 | 2023-11-01 18:21:53 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define _ <<" "<<
#define sz(x) ((int) (x).size())
typedef pair<int, int> pii;
typedef long long ll;
const int maxn = 2000 + 5;
int n, m;
char A[maxn][maxn];
vector<int> pos[maxn];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for (int i = 1;i <= n; ++i) {
for (int j = 1;j <= m; ++j) {
cin >> A[i][j];
A[1][1] = '_';
if (A[i][j] == 'C') pos[i].push_back(j);
}
}
int ans = 0;
function<void(int,int)> go = [&](int x,int y) {
if (x > n) return;
// cout << ans _ x _ y << endl;
if (pos[x].empty() || pos[x].back() < y) {
go(x+1, y);
return;
}
int ty = pos[x].back();
while (!pos[x].empty() && pos[x].back() >= y) pos[x].pop_back();
go(x, ty);
};
for (int i = 1;i <= n; ++i) {
if (!pos[i].empty()) {
ans++;
go(i, 1);
}
}
cout << ans << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3692kb
input:
4 4 __C_ C_C_ _C_C _CCC
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
4 6 CC____ _CCC__ ___C_C C__CCC
output:
2
result:
ok single line: '2'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
3 5 CC__C _C_CC CCCCC
output:
3
result:
ok single line: '3'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
4 4 __C_ CCCC ___C _C_C
output:
2
result:
ok single line: '2'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3696kb
input:
1 1 _
output:
0
result:
ok single line: '0'
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3852kb
input:
1 1 C
output:
0
result:
wrong answer 1st lines differ - expected: '1', found: '0'