이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
#define pi pair <int, int>
#define ppi pair <pi, int>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << ": " << x << '\n'
#define debug2(x, y) cout << #x << ": " << x << ' ' << #y << ": " << y << '\n'
#define debug3(x, y, z) cout << #x << ": " << x << ' ' << #y << ": " << y << ' ' << #z << ": " << z << '\n'
using namespace std;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());
const int inf = 1000000000;
int h, w, ans;
char grid[3005][3005];
int suffrow[3005][3005], suffcol[3005][3005]; //row count orb, column count ingot
signed main(){
ios::sync_with_stdio(0), cin.tie(0);
cin >> h >> w;
for(int i = 1; i <= h; i++) for(int j = 1; j <= w; j++) cin >> grid[i][j];
for(int i = 1; i <= h; i++) for(int j = w; j >= 1; j--){
suffrow[i][j] = suffrow[i][j+1];
if(grid[i][j] == 'O') suffrow[i][j]++;
}
for(int j = 1; j <= w; j++) for(int i = h; i >= 1; i--){
suffcol[j][i] = suffcol[j][i+1];
if(grid[i][j] == 'I') suffcol[j][i]++;
}
for(int i = 1; i < h; i++) for(int j = 1; j < w; j++){
if(grid[i][j] != 'J') continue;
ans += suffrow[i][j+1] * suffcol[j][i+1];
}
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... |