Submission #1152379

#TimeUsernameProblemLanguageResultExecution timeMemory
1152379tegsheeBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
492 ms150384 KiB
#include<bits/stdc++.h>
#define int long long
#define ss second
#define ff first
#define pb push_back
using namespace std;
const int mxn=3005;
char ch[mxn][mxn];
int a[mxn][mxn],b[mxn][mxn];
signed main() {
	int n,k;
	cin>>n>>k;
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=k; j++) {
			cin>>ch[i][j];
		} 
	}
	for(int i=1; i<=n; i++) {
		for(int j=k; j>=1; j--) {
			if(ch[i][j]=='O') {
				a[i][j]=a[i][j+1]+1;
			} else {
				a[i][j]=a[i][j+1];
			}
		}
	}
	for(int i=1; i<=k; i++) {
		for(int j=n; j>=1; j--) {
			if(ch[j][i]=='I') {
				b[j][i]=b[j+1][i]+1;
			} else {
				b[j][i]=b[j+1][i];
			}
		}
	}
	int s=0;
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=k; j++) {
			if(ch[i][j]=='J') {
				s+=a[i][j]*b[i][j];
			}
		}
	}
	cout<<s;
    
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...