# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
110682 | Breno_XD | Bitaro the Brave (JOI19_ho_t1) | C++14 | 1069 ms | 135332 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;
const int MAXN = 3200;
int N,M;
long long ans;
int matriz[MAXN][MAXN];
int row[MAXN][MAXN], r;
int column[MAXN][MAXN], c;
vector<pair<int,int> > calcula;
char letra;
int main(){
//Leitura
scanf("%d%d", &N, &M);
for(int i=1; i<=N; i++){
for(int j=1; j<=M; j++){
cin >> letra;
if(letra=='J') calcula.push_back({i,j});
if(letra=='I') matriz[i][j]=1;
if(letra=='O') column[i][j]+=++c;
else column[i][j]=c;
}
c=0;
}
for(int i=0; i<=M; i++){
for(int j=N; j>=1; j--){
if(matriz[j][i]==1) row[j][i]+=++r;
else row[j][i]=r;
column[j][i] = column[j][M]-column[j][i];
}
r=0;
}
/*
cout << endl;
for(int i=1; i<=N; i++){
for(int j=1; j<=M; j++){
cout << matriz[i][j] << " ";
}
cout << endl;
}
cout << endl;
cout << endl;
for(int i=1; i<=N; i++){
for(int j=1; j<=M; j++){
cout << row[i][j] << " ";
}
cout << endl;
}
cout << endl;
cout << endl;
for(int i=1; i<=N; i++){
for(int j=1; j<=M; j++){
cout << column[i][j] << " ";
}
cout << endl;
}
cout << endl;
*/
for(int i=0; i<calcula.size(); i++){
int k = calcula[i].first, l = calcula[i].second;
ans+=column[k][l]*row[k][l];
}
/*
for(int i=1; i<=N; i++)
for(int j=1; j<=M; j++)
if(matriz[i][j]==-1) ans+= column[i][j]*row[i][j];
*/
printf("%lld", ans);
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... |