이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
#define pb push_back
#define f first
#define s second
int main() {
int H, W;
cin >> H >> W;
int grid[H][W];
for (int i = 0; i < H; i++) {
string line;
cin >> line;
for (int j = 0; j < W; j++) {
grid[i][j] = line[j];
}
}
vi vCnts(W, 0);
ll ans = 0;
for (int i = H - 1; i >= 0; i--) {
int hCnt = 0;
for (int j = W - 1; j >= 0; j--) {
if (grid[i][j] == 'J') {
ans += (ll) hCnt * vCnts[j];
}
if (grid[i][j] == 'O') {
hCnt++;
}
if (grid[i][j] == 'I') {
vCnts[j]++;
}
}
}
cout << ans << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |