이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0);
int n, m; cin >> n >> m;
vector<pair<int,int>> jw;
vector<vector<int>> orb, ing;
orb = ing = vector<vector<int>>(n, vector<int>(m));
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
char c; cin >> c;
if(c == 'J') jw.emplace_back(i, j);
else if(c == 'I') ing[i][j]++;
else if(c == 'O') orb[i][j]++;
}
}
for(int i = 0; i < n; i++){
for(int j = m - 2; j >= 0; j--){
orb[i][j] += orb[i][j + 1];
}
}
for(int i = 0; i < m; i++){
for(int j = n - 2; j >= 0; j--){
ing[j][i] += ing[j+1][i];
}
}
int res = 0;
for(pair<int,int> j : jw){
res += orb[j.first][j.second] * ing[j.first][j.second];
}
cout << res << '\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... |