제출 #612213

#제출 시각아이디문제언어결과실행 시간메모리
612213nohaxjustsofloBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
97 ms89360 KiB
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> order_set;
mt19937 mt_rand(chrono::high_resolution_clock::now().time_since_epoch().count());
//uniform_int_distribution<int> gen; ///(min, max)
//int random() {return gen(mt_rand);}
const int mxN=3003;
const int mod=998244353;
const int mxlogN=40;
const int mxK=26;
const ll inf=1e18;
const int K=600;

int rig[mxN][mxN], down[mxN][mxN];
string s[mxN];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int m, n; cin >> m >> n;
    for(int j=0; j<m; j++) cin >> s[j];
    ll ans=0;
    for(int j=m-1; j>=0; j--)
    {
        for(int i=n-1; i>=0; i--)
        {
            rig[j][i]=rig[j][i+1]+(s[j][i]=='O');
            down[j][i]=down[j+1][i]+(s[j][i]=='I');
            if(s[j][i]=='J') ans+=rig[j][i]*down[j][i];
        }
    }
    cout << ans << "\n";
}
/*
7 3
4 1 3 4 0 2 3
*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...