Submission #544087

#TimeUsernameProblemLanguageResultExecution timeMemory
544087QuantumK9Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
303 ms88456 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back #define mp make_pair #define mt make_tuple using namespace std; void solve(){ int h, w; cin >> h >> w; char g[h][w]; for( int i = 0; i < h; i++ ){ for( int j = 0; j < w; j++ ){ cin >> g[i][j]; } } int pci[h][w]; memset( pci, 0, sizeof pci ); for( int i = h-2; i >= 0; i-- ){ for( int j = 0; j < w; j++ ){ pci[i][j] = pci[i+1][j] + ( g[i+1][j] == 'I' ); } } int pco[h][w]; memset( pco, 0, sizeof pco ); for( int j = w-2; j >= 0; j-- ){ for( int i = 0; i < h; i++ ){ pco[i][j] = pco[i][j+1] + ( g[i][j+1] == 'O' ); } } ll total = 0; for( int i = 0; i < h; i++ ){ for( int j = 0; j < w; j++ ){ if( g[i][j] == 'J' ){ total += pci[i][j]*pco[i][j]; } } } cout << total << endl; return; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; //cin >> t; while (t--) { solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...