제출 #196989

#제출 시각아이디문제언어결과실행 시간메모리
196989combi1k1Bitaro the Brave (JOI19_ho_t1)C++14
100 / 100
87 ms9244 KiB
#include<bits/stdc++.h>

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 2e5 + 5;

typedef pair<int,int>   ii;

ll  f[3005];

int main()  {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int n;  cin >> n;
    int m;  cin >> m;

    ll  ans = 0;

    for(int i = 0 ; i < n ; ++i)    {
        string s;   cin >> s;

        int cnt = 0;

        for(int j = m - 1 ; j >= 0 ; --j)   {
            if (s[j] == 'O')
                cnt++;
            if (s[j] == 'J')
                f[j] += cnt;
            if (s[j] == 'I')
                ans += f[j];
        }
    }
    cout << ans << endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...