Submission #521274

#TimeUsernameProblemLanguageResultExecution timeMemory
521274AdamGSBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
273 ms160044 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define rep(a, b) for(int a = 0; a < (b); ++a) #define st first #define nd second #define pb push_back #define all(a) a.begin(), a.end() const int LIM=3e3+7; string T[LIM]; ll lewo[LIM][LIM], dol[LIM][LIM]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; rep(i, n) { cin >> T[i]; for(int j=m-1; j>=0; --j) lewo[i][j]=lewo[i][j+1]+(T[i][j]=='O'); } rep(j, m) { for(int i=n-1; i>=0; --i) dol[i][j]=dol[i+1][j]+(T[i][j]=='I'); } ll ans=0; rep(i, n) rep(j, m) if(T[i][j]=='J') ans+=lewo[i][j]*dol[i][j]; cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...