# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
110674 | Breno_XD | Bitaro the Brave (JOI19_ho_t1) | C++14 | 206 ms | 12796 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 = 1100;
int N,M;
long long ans;
int matriz[MAXN][MAXN];
int row[MAXN][MAXN], r;
int column[MAXN][MAXN], c;
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') matriz[i][j]=-1;
if(letra=='I') matriz[i][j]=1;
if(letra=='O') column[i][j]+=++c;
else column[i][j]=c;
}
c=0;
}
for(int i=1; i<=M; i++){
for(int j=1; j<=N; j++){
if(matriz[j][i]==1) row[j][i]+=++r;
else row[j][i]=r;
}
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=1; i<=N; i++)
for(int j=1; j<=M; j++)
if(matriz[i][j]==-1) ans+= (column[i][M]-column[i][j])*(row[N][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... |