Submission #1258713

#TimeUsernameProblemLanguageResultExecution timeMemory
1258713dovietanhBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
112 ms9312 KiB
#include <bits/stdc++.h>
using namespace std;
char a[3005][3005];
long long row[3005];
long long col[3005];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int h,w;
    cin >> h >> w;
    for(int i = 1;i<=h;i++){
        for(int j = 1;j<=w;j++){
            cin >> a[i][j];
        }
    }

    long long res = 0;
    
    for(int i = h;i>=1;i--){
        for(int j = w;j>=1;j--){
            if(a[i][j] == 'J') res += row[i] * col[j];
            if(a[i][j] == 'I') col[j]++;
            if(a[i][j] == 'O') row[i]++;
        }
    }
    
    cout << res << '\n';
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...