# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
640956 | kkkkkkkk | Bitaro the Brave (JOI19_ho_t1) | C++14 | 667 ms | 118484 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;
int main()
{
int n,m;
cin >> n >> m;
char c[n][m];
vector<pair<int,int> > vj;
int mat_o[n][m],mat_i[n][m];
for (int i=0;i<n;i++)
for (int j=0;j<m;j++)
{
cin >> c[i][j];
if (c[i][j]=='J')
vj.push_back({i,j});
}
for (int i=0;i<m;i++){
if (c[n-1][i]=='I') mat_i[n-1][i]=1;
else mat_i[n-1][i]=0;
}
for (int i=n-2;i>=0;i--)
for (int j=m-1;j>=0;j--){
if (c[i][j]=='I') mat_i[i][j]=mat_i[i+1][j]+1;
else mat_i[i][j]=mat_i[i+1][j];
}
for (int i=0;i<n;i++){
if (c[i][m-1]=='O') mat_o[i][m-1]=1;
else mat_o[i][m-1]=0;
}
for (int i=n-1;i>=0;i--)
for (int j=m-2;j>=0;j--){
if (c[i][j]=='O') mat_o[i][j]=mat_o[i][j+1]+1;
else mat_o[i][j]=mat_o[i][j+1];
}
long long brojac=0;
for (int i=0;i<vj.size();i++)
{
int index_i=vj[i].first,index_j=vj[i].second;
brojac+=mat_o[index_i][index_j]*mat_i[index_i][index_j];
}
cout << brojac << endl;
return 0;
}
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... |