Submission #646831

#TimeUsernameProblemLanguageResultExecution timeMemory
646831perchutsBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
137 ms160304 KiB
#include <bits/stdc++.h> #define all(x) x.begin(), x.end() #define sz(x) (int) x.size() #define endl '\n' #define pb push_back #define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); using namespace std; using ll = long long; using ull = unsigned long long; using ii = pair<int,int>; using iii = tuple<int,int,int>; const int inf = 2e9+1; const int mod = 1e9+7; const int maxn = 3010; template<typename X, typename Y> bool ckmin(X& x, const Y& y) { return (y < x) ? (x=y,1):0; } template<typename X, typename Y> bool ckmax(X& x, const Y& y) { return (x < y) ? (x=y,1):0; } string grid[maxn]; ll suf1[maxn][maxn], suf2[maxn][maxn]; int main(){_ int h,w;cin>>h>>w; for(int i=0;i<h;++i)cin>>grid[i]; ll ans = 0; for(int i=h-1;~i;--i){ for(int j=w-1;~j;--j){ suf1[i][j] = suf1[i][j+1] + (grid[i][j]=='O'); suf2[i][j] = suf2[i+1][j] + (grid[i][j]=='I'); } } for(int i=0;i<h;++i) for(int j=0;j<w;++j) if(grid[i][j]=='J')ans += suf1[i][j]*suf2[i][j]; cout<<ans<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...