Submission #164801

#TimeUsernameProblemLanguageResultExecution timeMemory
164801cbertramBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
838 ms115352 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
#define all(x) x.begin(), x.end()
#define rep(i,a,b) for(int i = a; i < b; i++)

int main() {
  int H, W;
  cin >> H;
  cin >> W;
  vvi jewel(H, vi(W));
  vvi orb(H, vi(W));
  vvi ingot(H, vi(W));
  rep(h,0,H) {
    string line;
    cin >> line;
    rep(w,0,W) {
      if(line[w] == 'J')
	jewel[h][w] = 1;
      else if(line[w] == 'O')
	orb[h][w] = 1;
      else
	ingot[h][w] = 1;
    }
  }
  for(int h = H-2; h >= 0; h--)
    rep(w,0,W)
      ingot[h][w] += ingot[h+1][w];
  for(int w = W-2; w >= 0; w--)
    rep(h,0,H)
      orb[h][w] += orb[h][w+1];
  
  long sum = 0;
  rep(h,0,H) {
    rep(w,0,W) {
      sum += ((long)orb[h][w])*((long)ingot[h][w])*((long)jewel[h][w]);
    }
  }
  cout << sum << '\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...