제출 #698035

#제출 시각아이디문제언어결과실행 시간메모리
698035Sandarach151Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
151 ms86424 KiB
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int h, w; cin >> h >> w; string arr[h]; for(int i=0; i<h; i++){ cin >> arr[i]; } int ingots[h][w]; for(int i=0; i<w; i++){ if(arr[h-1][i]=='I'){ ingots[h-1][i]=1; } else{ ingots[h-1][i]=0; } } for(int i=h-2; i>=0; i--){ for(int j=0; j<w; j++){ ingots[i][j]=ingots[i+1][j]; if(arr[i][j]=='I'){ ingots[i][j]++; } } } int orbs[h][w]; for(int i=0; i<h; i++){ if(arr[i][w-1]=='O'){ orbs[i][w-1]=1; } else{ orbs[i][w-1]=0; } } for(int i=0; i<h; i++){ for(int j=w-2; j>=0; j--){ orbs[i][j]=orbs[i][j+1]; if(arr[i][j]=='O'){ orbs[i][j]++; } } } long long finans = 0; for(int i=0; i<h; i++){ for(int j=0; j<w; j++){ if(arr[i][j]=='J'){ finans += (long long) (orbs[i][j]*ingots[i][j]); } } } cout << finans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...