Submission #1349897

#TimeUsernameProblemLanguageResultExecution timeMemory
1349897sameerBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
241 ms150500 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
ll i, j, ans, k, n, h, w, oo[3007][3007], ii[3007][3007]; char s[3007][3007];

void run(){
 cin >> h >> w;
 for( i = 1; i <= h; i++){
 for( j = 1; j <= w; j++) cin >> s[i][j];
 }
 for( i = 1; i <= h; i++){
 for( j = w; j >= 1; j--) oo[i][j] += oo[i][j+1]+(s[i][j] == 'O');
 }
 for( j = 1; j <= w; j++){
 for( i = h; i >= 1; i--) ii[i][j] += ii[i+1][j]+(s[i][j] == 'I');
 } ans = 0;
 for( i = 1; i <= h; i++){
 for( j = 1; j <= w; j++) if(s[i][j] == 'J') ans += ii[i][j]*oo[i][j];
 } cout << ans << '\n';
}

int main(){
 ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 // int tt; cin >> tt; while(tt--)
 run();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...