Submission #1027200

#TimeUsernameProblemLanguageResultExecution timeMemory
1027200vjudge1Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
239 ms150640 KiB
#include <bits/stdc++.h>
typedef long double ld;
#define int long long
#define TC int t; cin >> t; for(int _=1; _<=t; _++)
#define bismillah ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
using namespace std;

const int N = 3007;

char a[N][N];

int prefo[N][N];
int prefi[N][N];

signed main(){
   bismillah;
   int n, m; cin >> n >> m;

   for(int i=1; i<=n; i++){
      for(int j=1; j<=m; j++){
         cin >> a[i][j];
         char c = a[i][j];

         prefo[i][j]+=prefo[i][j-1];
         prefi[i][j]+=prefi[i-1][j];
         if(c=='O'){
            prefo[i][j]++;
         }else if(c=='I'){
            prefi[i][j]++;
         }
      }
   }

   int ans = 0;
   for(int i=1; i<=n; i++){
      for(int j=1; j<=m; j++){
         if(a[i][j]=='J'){
            int O = prefo[i][m]-prefo[i][j];
            int I = prefi[n][j]-prefi[i][j];
            ans+=(O*I);
         }
      }
   } 
   cout << ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...