이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define mp make_pair
#define pb push_back
using namespace std;
ll n, m, rez = 0;
char mat[3030][3030];
int main(){
cin>>n>>m;
for(int i = 0; i < n; i++){
string a;
cin>>a;
for(int j = 0; j < m; j++){
mat[i][j] = a[j];
}
}
int row[n][m], col[n][m];
memset(row,0,sizeof(row));
for(int i = 0; i < n;i++){
int cur = 0;
for(int j = m - 1; j >= 0; j--){
if(mat[i][j]=='O')
cur++;
row[i][j] = cur;
}
}
memset(col,0,sizeof(col));
for(int j = 0; j < m; j++){
int cur = 0;
for(int i = n - 1; i >= 0; i--){
if(mat[i][j] == 'I')
cur++;
col[i][j] = cur;
}
}
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
if(mat[i][j] == 'J' && i + 1 < n && j + 1 < m){
ll lcnt = row[i][j+1], kcnt = col[i + 1][j];
rez += (kcnt * lcnt);
}
else
continue;
}
}
cout<<rez<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |