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 optimize("O2,unroll-loops")
//#pragma GCC target("avx,avx2")
#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r)
{
return l+rng()%(r-l+1);
}
#define fasty ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define forinc(x,a,b) for(int x=a;x<=b;x++)
#define fordec(x,a,b) for(int x=a;x>=b;x--)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<long long,long long>
#define getbit(x,i) ((x>>(i))&1)
#define batbit(x,i) (x|(1ll<<(i)))
#define tatbit(x,i) (x&~(1<<(i)))
#define gg exit(0);
#define all(a) a.begin() , a.end()
const int N = 3010;
char a[N][N];
int m , n;
int cntO[N][N];
int cntI[N][N];
main()
{
fasty;
cin >> m >> n;
forinc(i,1,m) forinc(j,1,n) cin >> a[i][j];
long long tot=0;
forinc(i,1,m) fordec(j,n,1)
{
if(a[i][j] == 'O') cntO[i][j] = cntO[i][j+1] + 1;
else cntO[i][j] = cntO[i][j+1];
}
fordec(i,m,1) forinc(j,1,n)
{
if(a[i][j] == 'I') cntI[i][j] = cntI[i+1][j] + 1;
else cntI[i][j] = cntI[i+1][j];
}
forinc(i,1,m) forinc(j,1,n) if(a[i][j] == 'J')
{
tot += cntI[i][j] * cntO[i][j];
}
cout << tot;
}
Compilation message (stderr)
joi2019_ho_t1.cpp:29:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
29 | main()
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |