제출 #99969

#제출 시각아이디문제언어결과실행 시간메모리
99969oolimryBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
530 ms114824 KiB
#include <bits/stdc++.h> using namespace std; int main() { //freopen("i.txt","r",stdin); cin.tie(0); ios_base::sync_with_stdio(false); int rows, cols; cin >> rows >> cols; int arr[rows][cols]; for(int r = 0;r < rows;r++){ string s; cin >> s; for(int c = 0;c < cols;c++){ if(s[c] == 'J') arr[r][c] = 0; else if(s[c] == 'O') arr[r][c] = 1; else arr[r][c] = 2; } } int O[rows][cols]; int I[rows][cols]; for(int r = 0;r < rows;r++){ for(int c = 0;c < cols;c++){ O[r][c] = 0; I[r][c] = 0; } } for(int r = 0;r < rows;r++){ for(int c = cols-1;c >= 0;c--){ if(arr[r][c] == 1) O[r][c]++; if(c != cols-1) O[r][c] += O[r][c+1]; } } for(int c = 0;c < cols;c++){ for(int r = rows-1;r >= 0;r--){ if(arr[r][c] == 2) I[r][c]++; if(r != rows-1) I[r][c] += I[r+1][c]; } } long long ans = 0ll; for(int r = 0;r < rows;r++){ for(int c = 0;c < cols;c++){ if(arr[r][c] == 0){ long long x = O[r][c]; long long y = I[r][c]; ans += x * y; } } } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...