This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// -*- compile-command: "g++ -g -Wno-return-type -Wall -Wextra -DLOCAL -std=c++17 -D_GLIBCXX_DEBUG ho_t1.cpp -oho_t1 && ./ho_t1 " -*-
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
#define int LL
#define vc vector
#define pb push_back
#define pr pair
#define fi first
#define se second
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define f(i,n) for(int i=0;i<(n);i++)
#define fr(i,n) for(int i=(n);i--;)
#define fv(i,v) f(i,sz(v))
main(){
ios::sync_with_stdio(0),cin.tie(0);
int h,w;
cin>>h>>w;
vc<string> s(h);
f(i,h) cin>>s[i];
vc<vc<int>> ning(h,vc<int>(w));
vc<vc<int>> norb(h,vc<int>(w));
fr(i,h) fr(j,w){
ning[i][j]+=(s[i][j]=='I')+(i+1<h?ning[i+1][j]:0);
norb[i][j]+=(s[i][j]=='O')+(j+1<w?norb[i][j+1]:0);
}
int r=0;
f(i,h) f(j,w){
if(s[i][j]=='J') r+=ning[i][j]*norb[i][j];
}
cout<<r<<'\n';
}
Compilation message (stderr)
joi2019_ho_t1.cpp:17:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
17 | 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... |