이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
void Solve() {
int h, w;
cin >> h >> w;
char a[h][w];
for(int i = 0; i < h; i++) {
for(int j = 0; j < w; j++) {
cin >> a[i][j];
}
}
int orbRow[h], ingotCol[w];
for(int i = 0; i < h; i++) {
orbRow[i] = 0;
}
for(int i = 0; i < w; i++) {
ingotCol[i] = 0;
}
for(int i = 0; i < h; i++) {
for(int j = 0; j < w; j++) {
if(a[i][j] == 'O') {
orbRow[i]++;
}
if(a[i][j] == 'I') {
ingotCol[j]++;
}
}
}
int ans = 0;
for(int i = 0; i < h; i++) {
for(int j = 0; j < w; j++) {
if(a[i][j] == 'J') {
ans += orbRow[i] * ingotCol[j];
}
else if(a[i][j] == 'O') {
orbRow[i]--;
}
else {
ingotCol[j]--;
}
}
}
cout << ans << "\n";
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
Solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |