# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1232637 | Bui_Quoc_Cuong | Bitaro the Brave (JOI19_ho_t1) | C++20 | 371 ms | 318004 KiB |
# include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = a; i <= (int)b; i++)
#define FORD(i, a, b) for (int i = a; i >= (int)b; i--)
const int MAXN = 3005;
int n, m;
int a[MAXN][MAXN];
int cntRow[MAXN][MAXN][4], cntCol[MAXN][MAXN][4];
signed main(){
cin.tie(nullptr) -> sync_with_stdio(false);
#define taskname "kieuoanh"
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
freopen(taskname".out", "w", stdout);
}
cin >> n >> m;
FOR(i, 1, n) FOR(j, 1, m){
char x; cin >> x;
if(x == 'J') a[i][j] = 1;
if(x == 'O') a[i][j] = 2;
if(x == 'I') a[i][j] = 3;
}
FOR(t, 1, 3){
FOR(i, 1, n){
FOR(j, 1, m){
cntRow[i][j][t] = cntRow[i][j - 1][t] + (a[i][j] == t);
cntCol[i][j][t] = cntCol[i - 1][j][t] + (a[i][j] == t);
}
}
}
long long ans = 0;
FOR(i, 1, n) FOR(j, 1, m){
if(a[i][j] == 1){
int cnt2 = cntRow[i][m][2] - cntRow[i][j - 1][2];
int cnt3 = cntCol[n][j][3] - cntCol[i - 1][j][3];
ans+= 1LL * cnt2 * cnt3;
}
}
cout << ans;
return 0;
}
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... |