Submission #485206

#TimeUsernameProblemLanguageResultExecution timeMemory
485206chungdinhBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
262 ms91004 KiB
#include <cstdio>
#include <string>
#include <queue>
#include <iostream>

using namespace std;

#define endl "\n"
#define cntbit(x) __builtin_popcount(x)
#define on(b, x) (b & (1 << x))
#define all(x) x.begin(), x.end()
#define gcd __gcd
#define ll long long
#define ii pair<int, int>

const int N = 3e3 + 5;
const ll MOD = 998244353;
const int iINF = 1e9;
const ll INF = 1e18;

int n, m;
string g[N];

ii z[N][N];

int main() {
    #ifdef CHUNGDINH
    freopen("main.inp", "r", stdin);
    #endif

    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++) cin >> g[i];

    ll res = 0;

    for (int i = n - 1; i >= 0; i--) {
        for (int j = m - 1; j >= 0; j--) {
            ii &a = z[i][j];
            if (i == n - 1) a.first = 0;
            else a.first = z[i + 1][j].first + (g[i + 1][j] == 'I');

            if (j == m - 1) a.second = 0;
            else a.second = z[i][j + 1].second + (g[i][j + 1] == 'O');

            if (g[i][j] == 'J') res += (ll)a.first * a.second;
        }
    }

    printf("%lld", res);
}

Compilation message (stderr)

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     scanf("%d%d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...