# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
386778 | cpp219 | Bitaro the Brave (JOI19_ho_t1) | C++14 | 273 ms | 159364 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimization "Ofast"
#pragma GCC optimization "unroll-loop"
#pragma GCC target ("avx2")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
using namespace std;
const ll N = 3e3 + 6;
const ll Log2 = 19;
const ll inf = 1e16 + 7;
typedef pair<ll,ll> LL;
ll n,m,cntO[N][N],cntI[N][N];
char a[N][N];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
#define task "tst"
if (fopen(task".inp", "r")){
freopen(task".inp", "r", stdin);
//freopen(task".out", "w", stdout);
}
cin>>n>>m;
for (ll i = 1;i <= n;i++){
for (ll j = 1;j <= m;j++){
cin>>a[i][j];
cntI[i][j] = cntI[i - 1][j] + (a[i][j] == 'I');
cntO[i][j] = cntO[i][j - 1] + (a[i][j] == 'O');
}
}
ll ans = 0;
for (ll i = 1;i <= n;i++){
for (ll j = 1;j <= m;j++) if (a[i][j] == 'J'){
ll p = cntO[i][m] - cntO[i][j - 1],q = cntI[n][j] - cntI[i - 1][j];
ans += p*q;
}
}
cout<<ans;
}
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... |