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>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef pair<ld,ld> id;
#define FOR(i, a, b) for(int i=(a); i<=(b); i++)
#define ROF(i, a, b) for(int i=(a); i>=(b); i--)
#define MEM(x, v) memset(x, v, sizeof(x))
#define SORT(x) sort((x).begin(), (x).end())
#define CMPSORT(x, cp) sort((x).begin(), (x).end(), cp)
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define f first
#define s second
#define e emplace
#define eb emplace_back
#define ef emplace_front
#define ins insert
#define p push
#define pf push_front
#define pb push_back
#define mp make_pair
#define getchar_unlocked _getchar_nolock
#define INF ((long long)1e18)
#define MOD 1000000007
#define db cout<<"YEET\n";
#define ct(x) cout<<x<<'\n';
int main(){
FAST
ll h, w;
char grid[3010][3010];
cin >> h >> w;
FOR(i, 1, h){
FOR(j, 1, w){
cin >> grid[i][j];
}
}
ll power[3010], total=0;
MEM(power, 0);
FOR(i, 1, h){
FOR(j, 1, w){
if (grid[i][j]=='I') total+=power[j];
}
ll ocnt=0;
ROF(j, w, 1){
if (grid[i][j]=='O') ocnt++;
if (grid[i][j]=='J') power[j]+=ocnt;
}
}
cout << total;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |