Submission #501699

#TimeUsernameProblemLanguageResultExecution timeMemory
501699vinnipuh01Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
713 ms88360 KiB
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <stack>
#include <string>
#include <map>
#include <queue>
#define int long long

using namespace std;

const long long oo = 1000000000000000000;

long long sum, ans = 0, mx = 0, mn = 1000000000, num, pos;


/*
    ViHHiPuh

   (( `'-""``""-'` ))
     )-__-_.._-__-(
   / --- (o _ o) --- \
   \ .-* ( .0. ) *-. /
   _'-. ,_ '=' _, .-'_
  / `;#'#'# - #'#'#;` \
 \_)) -----'#'----- ((_/
      # --------- #
  '# ------- ------ #'
  /..-'# ------- #'-.\
  _\...-\'# -- #'/-.../_
  ((____)- '#' -(____))


    cout << fixed << setprecision(6) << x;

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    freopen ( "sum.in", "r", stdin )
*/

int n, m, mp[ 3001 ][ 3001 ];
char c[ 3001 ][ 3001 ];

main () {
	cin >> n >> m;
	for ( int i = 1; i <= n; i ++ ) {
		for ( int j = 1; j <= m; j ++ ) {
			cin >> c[ i ][ j ];
		}
	}
	for ( int i = 1; i <= n; i ++ ) {
		num = 0;
		for ( int j = m; j >= 1; j -- ) {
			if ( c[ i ][ j ] == 'O' )
				num ++;
			if ( c[ i ][ j ] == 'J' )
				mp[ i ][ j ] = num;
		}
	}
	for ( int j = 1; j <= m; j ++ ) {
		num = 0;
		for ( int i = n; i >= 1; i -- ) {
			if ( c[ i ][ j ] == 'I' )
				num ++;
			if ( c[ i ][ j ] == 'J' ) {
				ans += mp[ i ][ j ] * num;
			}
		}
	}
	cout << ans;
}


/*

(p[ i ] - p[j - 1] ) - (a[i] - a[j])
p[i] - p[j-1] - a[i] + a[j]
p[i] - a[i] - p[j-1] + a[j]

*/

Compilation message (stderr)

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