Submission #497620

#TimeUsernameProblemLanguageResultExecution timeMemory
497620penguin133Bitaro the Brave (JOI19_ho_t1)C++14
100 / 100
426 ms88548 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long

int dp[1000005], P[3005], S[3005], L[3005][3005];
char g[3005][3005];
priority_queue<int>pq;
pair<int, int> A[1000005];
main(){
	ios::sync_with_stdio(0);cin.tie(0);
	int h,w,ans = 0;
	cin >> h >> w;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++)cin >> g[i][j];
	}
	for(int i=1;i<=h;i++){
		for(int j=w;j>=1;j--)L[i][j] = L[i][j+1] + (g[i][j] == 'O');
	}
	for(int i=1;i<=w;i++){
		for(int j=1;j<=h;j++)P[j] = P[j-1] + (g[j][i] == 'J');
		for(int j=h;j>=1;j--)S[j] = S[j+1] + (g[j][i] == 'I');
		for(int j=1;j<=h;j++)ans += (g[j][i] == 'J') * S[j+1] * L[j][i+1];
	}
	cout << ans;
	
}

Compilation message (stderr)

joi2019_ho_t1.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...