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>
#define chmin(x, v) x = min(x, v)
#define chmax(x, v) x = max(x, v)
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
map<char, int> conversion = {{'I', 0}, {'J', 1}, {'O', 2}};
signed main(){
int nLigs, nCols; cin >> nLigs >> nCols;
int vals[nLigs][nCols];
int occsLig[nLigs][nCols][3], occsCol[nLigs][nCols][3];
for (int ilig = 0; ilig < nLigs; ++ilig){
for (int icol = 0; icol < nCols; ++icol){
char cara; cin >> cara;
vals[ilig][icol] = conversion[cara];
}
}
for (int icol = 0; icol < nCols; ++icol){
for (int color = 0; color < 3; ++color)
occsLig[nLigs - 1][icol][color] = 0;
occsLig[nLigs - 1][icol][vals[nLigs - 1][icol]]++;
for (int ind = nLigs - 2; ind >= 0; --ind){
for (int color = 0; color < 3; ++color)
occsLig[ind][icol][color] = occsLig[ind + 1][icol][color];
occsLig[ind][icol][vals[ind][icol]]++;
}
}
for (int ilig = 0; ilig < nLigs; ++ilig){
for (int color = 0; color < 3; ++color)
occsCol[ilig][nCols - 1][color] = 0;
occsCol[ilig][nCols - 1][vals[ilig][nCols - 1]]++;
for (int ind = nCols - 2; ind >= 0; --ind){
for (int color = 0; color < 3; ++color)
occsCol[ilig][ind][color] = occsCol[ilig][ind + 1][color];
occsCol[ilig][ind][vals[ilig][ind]]++;
}
}
int sum = 0;
for (int x = 0; x < nLigs; ++x)
for (int y = 0; y < nCols; ++y){
if (vals[x][y] == 1)
sum += occsCol[x][y][2] * occsLig[x][y][0];
}
cout << sum << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |