Submission #289659

#TimeUsernameProblemLanguageResultExecution timeMemory
289659rocks03Bitaro the Brave (JOI19_ho_t1)C++14
100 / 100
483 ms118392 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pld pair<long double, int> #define pii pair<int, int> #define pll pair<ll, ll> #define pb push_back #define ff first #define ss second #define SZ(x) ((int)(x).size()) #define ld long double mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int MAXN = 3e3+100; int H, W, a[MAXN][MAXN], cnt[2+1][MAXN][MAXN]; void read(){ cin >> H >> W; for(int i = 0; i < H; i++){ string s; cin >> s; for(int j = 0; j < W; j++){ if(s[j] == 'J') a[i][j] = 0; else if(s[j] == 'O') a[i][j] = 1; else if(s[j] == 'I') a[i][j] = 2; } } for(int i = 0; i < H; i++){ for(int j = W-1; j >= 0; j--){ cnt[1][i][j] += cnt[1][i][j+1]; if(a[i][j] == 1) cnt[1][i][j]++; } } for(int j = 0; j < W; j++){ for(int i = H-1; i >= 0; i--){ cnt[2][i][j] += cnt[2][i+1][j]; if(a[i][j] == 2) cnt[2][i][j]++; } } } void solve(){ read(); ll ans = 0; for(int i = 0; i < H; i++){ for(int j = 0; j < W; j++){ if(a[i][j] == 0){ ans += cnt[1][i][j] * cnt[2][i][j]; } } } cout << ans; } int main(){ ios_base::sync_with_stdio(false); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...