This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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];
int sum = 0;
rep(h,0,H) {
rep(w,0,W) {
sum += orb[h][w]*ingot[h][w]*jewel[h][w];
}
}
cout << sum << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |