# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1258699 | trantien3771 | Bitaro the Brave (JOI19_ho_t1) | C++17 | 166 ms | 150336 KiB |
#include <bits/stdc++.h>
#define int long long
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define se second
#define pii pair<int, int>
const int maxn = 1e6 + 5;
const int mod = 1e9 + 7;
using namespace std;
char a[3005][3005];
int pfo[3005][3005], pfi[3005][3005];
main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
if (fopen(".INP", "r"))
{
freopen(".INP", "r", stdin);
freopen(".OUT", "w", stdout);
}
int h, w; cin >> h >> w;
for (int i = 1; i <= h; i++){
for (int j = 1; j <= w; j++){
cin >> a[i][j];
}
}
for (int i = h; i >= 1; i--){
for (int j = w; j >= 1; j--){
pfo[i][j] = pfo[i][j + 1] + (a[i][j] == 'O');
pfi[i][j] = pfi[i + 1][j] + (a[i][j] == 'I');
// cout << pfo[i][j] << " ";
}
// cout << '\n';
}
int cnt = 0;
for (int i = 1; i <= h; i++){
for (int j = 1; j <= w; j++){
if (a[i][j] == 'J'){
cnt += pfo[i][j + 1] * pfi[i + 1][j];
}
}
}
cout << cnt;
return 0;
}
//TranTien
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |