# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
139594 | math0_0 | Bitaro the Brave (JOI19_ho_t1) | C++11 | 750 ms | 115372 KiB |
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 ll;
typedef pair<int, int> pi;
int main(){
int h, w;
cin >> h >> w;
string arr[h];
for(int one = 0; one < h; one++){
cin >> arr[one];
}
int sufO[h][w] = {0}, sufI[h][w] = {0};
vector<pi> jpos;
for(int one = h-1; one >= 0; --one){
for(int two = w-1; two >= 0; --two){
sufO[one][two] = 0; sufI[one][two] = 0;
if(arr[one][two] == 'J'){
jpos.push_back(make_pair(one, two));
if(two != w-1){sufO[one][two] = sufO[one][two+1];}
if(one != h-1){sufI[one][two] = sufI[one+1][two];}
}
else if(arr[one][two] == 'O'){
if(two == w-1){sufO[one][two] = 1;}
else{sufO[one][two] = sufO[one][two+1] + 1;}
if(one != h-1){sufI[one][two] = sufI[one+1][two];}
}else{
if(one == h-1){sufI[one][two] = 1;}
else{sufI[one][two] = sufI[one+1][two] + 1;}
if(two != w-1){sufO[one][two] = sufO[one][two+1];}
}
}
}
ll ans = 0;
for(int one = 0; one < jpos.size(); one++){
ll x = jpos[one].first;
ll y = jpos[one].second;
ll pwr = sufO[x][y+1]*sufI[x+1][y];
if(x==h-1 || y==w-1){pwr = 0;}
ans+=pwr;
}
cout << ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |