이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pll;
#define fastio ios::sync_with_stdio(false), cin.tie(0)
// #pragma GCC optimize("Ofast")
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define lowbit(x) x&-x
const int maxn = 3000 + 5;
const int INF = 1e9;
const double eps = 1e-7;
string s[maxn];
int r[maxn][maxn], d[maxn][maxn];
int main(void){
fastio;
int h, w;
cin>>h>>w;
for(int i = 0; i < h; i++) cin>>s[i];
for(int i = 0; i < h; i++){
int cnt = 0;
for(int j = w - 1; j >= 0; j--){
if(s[i][j] == 'O') cnt++;
if(s[i][j] == 'J') r[i][j] = cnt;
}
}
for(int j = 0; j < w; j++){
int cnt = 0;
for(int i = h - 1; i >= 0; i--){
if(s[i][j] == 'I') cnt++;
if(s[i][j] == 'J') d[i][j] = cnt;
}
}
ll ans = 0;
for(int i = 0; i < h; i++){
for(int j = 0; j < w; j++){
if(s[i][j] == 'J') ans += r[i][j] * d[i][j];
}
}
cout<<ans<<"\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |