이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e3+45;
char a[N][N];
int cnti[N][N],cnto[N][N];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int h,w;
cin >> h >> w;
for(int i = 1; i <= h; i++){
string s;
cin >> s;
for(int j = 1; j <= w; j++){
a[i][j] = s[j-1];
cnto[i][j] = cnto[i][j-1]+(a[i][j] == 'O');
}
}
for(int j = 1; j <= w; j++){
for(int i = 1; i <= h; i++){
cnti[j][i] = cnti[j][i-1]+(a[i][j] == 'I');
}
}
ll sol = 0;
for(int i = 1; i <= h; i++){
for(int j = 1; j <= w; j++){
if(a[i][j] != 'J'){
continue;
}
ll iovi = cnti[j][h]-cnti[j][i-1],oovi = cnto[i][w]-cnto[i][j-1];
sol += iovi*oovi;
}
}
cout << sol << 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... |