Submission #794258

#TimeUsernameProblemLanguageResultExecution timeMemory
794258dimashhhBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
308 ms91520 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 3e3 + 123; int n,m; char a[3100][3100]; int so[N][N],si[N][N]; void test(){ cin >> n >> m; for(int i=1;i<=n;i++){ for(int j = 1;j <= m;j++){ cin >> a[i][j]; } } for(int i = 1;i <= n;i++){ for(int j = m;j >= 1;j--){ so[i][j] = so[i][j + 1] + (a[i][j] == 'O'); } } for(int i = 1;i <= m;i++){ for(int j = n;j >= 1;j--){ si[j][i] = si[j + 1][i] + (a[j][i] == 'I'); } } ll res = 0; for(int i = 1;i <= n;++i){ for(int j = 1;j <= m;j++){ if(a[i][j] == 'J'){ res += so[i][j + 1] * 1ll * si[i + 1][j]; } } } cout << res; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int t = 1; //cin >> t; while(t--) test(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...