This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define endl '\n';
typedef long long ll;
int H,W;
string S[3005];
ll ans = 0;
void searchC (int i , int j , char c) {
if(c == 'I') {
for(int k = i + 1; k <= H; k++) {
if(S[k][j] == 'I') {
searchC(i,j,'O');
}
}
}
else if (c == 'O') {
for(int l = j + 1; l <= W; l++) {
if(S[i][l] == 'O') {
ans += 1;
//cout << i << " " << j << endl;
}
}
}
return;
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
cin >> H >> W;
for(int i = 1; i<= H; i++) {
string s; cin >> s;
S[i] = s;
//cout << S[i] << endl;
}
for(int i = 1; i <= H; i++) {
for(int j = 0; j < W; j++) {
if(S[i][j] == 'J') {
//cout << i << " " << j;
searchC(i,j,'I');
}
}
}
cout << ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |