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