이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN = 3010;
int grid[MAXN][MAXN];
int ing[MAXN][MAXN],orb[MAXN][MAXN];
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int H,W; cin >> H >> W; //count for every J how many O's are in the row after it and how many I's are in the column after it
for(int i = 0;i<H;++i){
string s; cin >> s;
for(int j = 0;j<W;++j){
grid[i][j] = s[j];
}
}
for(int i = 0;i<H;++i){
int cnt = 0;
for(int j = W-1;j>=0;--j){
if(grid[i][j] == 'J'){
orb[i][j] = cnt;
}
else if(grid[i][j] == 'O'){
cnt++;
}
}
}
for(int i = 0;i<W;++i){
int cnt = 0;
for(int j = H-1;j>=0;--j){
if(grid[j][i] == 'J'){
ing[j][i] = cnt;
}
else if(grid[j][i] == 'I'){
cnt++;
}
}
}
ll ans = 0;
for(int i = 0;i<H;++i){
for(int j = 0;j<W;++j){
if(grid[i][j] == 'J'){
//cout << ing[i][j] << " " << orb[i][j] << "\n";
ans += ing[i][j]*orb[i][j];
}
}
}
cout << ans << "\n";
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... |