이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb push_back
#define epb emplace_back
using namespace std;
int prefr[3001][3001], prefc[3001][3001];
int main(){
int n, m; cin >> n >> m;
char c[n + 1][m + 1];
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++) cin >> c[i][j];
}
for(int i = 1; i <= n; i++){
prefr[i][0] = 0;
for(int j = 1; j <= m; j++) {
prefr[i][j] = prefr[i][j - 1];
if(c[i][j] == 'O') prefr[i][j]++;
}
}
for(int j = 1; j <= m; j++){
prefc[0][j] = 0;
for(int i = 1; i <= n; i++){
prefc[i][j] = prefc[i - 1][j];
if(c[i][j] == 'I') prefc[i][j]++;
}
}
ll ans = 0;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
if(c[i][j] == 'J'){
ll x = prefr[i][m] - prefr[i][j];
ll y = prefc[n][j] - prefc[i][j];
ans += x * y;
}
}
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |