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>
#define F first
#define S second
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
using namespace std;
const int INF = 1000000007;
const int N = 3005;
char a[N][N];
int po[N][N], pi[N][N];
int main() {
ios_base :: sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cin >> a[i][j];
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
po[i][j] = po[i][j - 1] + (a[i][j] == 'O');
}
}
for (int j = 0; j < m; j++) {
for (int i = 0; i < n; i++) {
pi[i][j] = pi[i - 1][j] + (a[i][j] == 'I');
}
}
int co, ci;
long long res = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (a[i][j] == 'J') {
co = po[i][m - 1] - po[i][j - 1];
ci = pi[n - 1][j] - pi[i - 1][j];
res += 1LL * co * ci;
}
}
}
cout << res << endl;
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... |