이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int H, W;
vector<string> V;
void solve(){
cin>>H>>W;
V.assign(H, "");
for(int i = 0; i < H; i++) cin>>V[i];
long long ans = 0;
vector<int> orbInRow(H, 0), ingotInCol(W, 0);
for(int i = 0; i < H; i++)
for(int j = 0; j < W; j++) orbInRow[i] += V[i][j] == 'O';
for(int i = 0; i < W; i++)
for(int j = 0; j < H; j++) ingotInCol[i] += V[j][i] == 'I';
for(int i = 0; i < H; i++){
for(int j = 0; j < W; j++){
if(V[i][j] == 'O') orbInRow[i]--;
if(V[i][j] == 'I') ingotInCol[j]--;
if(V[i][j] != 'J') continue;
// mi servono gli ingot sotto i
ans += (long long)orbInRow[i] * (long long)ingotInCol[j];
// cout<<"DEBUG-->"<<i+1<<" "<<j+1<<" "<<orbInRow[i] * ingotInCol[j]<<endl;
}
}
cout<<ans<<endl;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
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... |