이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int h, w;
cin >> h >> w;
vector<string> v(h);
for (int i = 0; i < h;++i){
cin >> v[i];
}
vector<vector<int>> prefo(h, vector<int> (w));
vector<vector<int>> prefi(h, vector<int> (w));
for (int i = 0; i < w; ++i){
for (int j = 1; j < h; ++j){
if (v[j][i] == 'I')prefi[j][i] = prefi[j-1][i]+1;
else prefi[j][i] = prefi[j-1][i];
}
}
for (int i = 0; i < h; ++i){
for (int j = 1; j < w; ++j){
if (v[i][j] == 'O')prefo[i][j] = prefo[i][j-1]+1;
else prefo[i][j] = prefo[i][j-1];
}
}
int ans = 0;
for (int i = 0; i < h-1; ++i){
for (int j = 0; j < w-1; ++j){
if (v[i][j] == 'J'){
ans += (prefo[i][w-1]-prefo[i][j]) * (prefi[h-1][j] - prefi[i][j]);
}
}
}
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... |