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