Submission #174132

#TimeUsernameProblemLanguageResultExecution timeMemory
174132AlexLuchianovBitaro the Brave (JOI19_ho_t1)C++14
50 / 100
1046 ms87940 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[1 + nmax][1 + nmax];
int ingots[1 + nmax][1 + nmax], orbs[1 + nmax][1 + nmax];

int main()
{
  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...