Submission #174138

#TimeUsernameProblemLanguageResultExecution timeMemory
174138AlexLuchianovBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
401 ms88584 KiB
#include <iostream>

using namespace std;

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 3000;
char v[5 + nmax][5 + nmax];
int ingots[5 + nmax][5 + nmax], orbs[5 + nmax][5 + nmax];

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  int n, m;
  cin >> n >> m;
  for(int i = 1;i <= n; i++)
    for(int j = 1;j <= m; j++) {
      cin >> v[i][j];
      if(v[i][j] == 'O')
        orbs[i][j]++;
      else if(v[i][j] == 'I')
        ingots[i][j]++;
    }

  for(int i = n; 1 <= i; i--)
    for(int j = m; 1 <= j; j--) {
      orbs[i][j] += orbs[i][j + 1];
      ingots[i][j] += ingots[i + 1][j];
    }

  ll result = 0;
  for(int i = 1;i <= n; i++)
    for(int j = 1;j <= m; j++)
      if(v[i][j] == 'J') {
        result += orbs[i][j] * ingots[i][j];
      }
  cout << result << '\n';
  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...