Submission #589882

#TimeUsernameProblemLanguageResultExecution timeMemory
589882boris_mihovBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
84 ms88572 KiB
#include <iostream>

typedef long long llong;
const int MAXN = 3000 + 10;

int n, m;
char t[MAXN][MAXN];
int countO[MAXN][MAXN];
int countI[MAXN][MAXN];

void solve()
{
    llong ans = 0;
    for (int i = n ; i >= 1 ; --i)
    {
        for (int j = m ; j >= 1 ; --j)
        {
            countI[i][j] = countI[i + 1][j] + (t[i][j] == 'I');
            countO[i][j] = countO[i][j + 1] + (t[i][j] == 'O');

            if (t[i][j] == 'J')
            {
                ans += countI[i][j] * countO[i][j];
            }
        }
    }

    std::cout << ans << '\n';
}

void read()
{
    std::cin >> n >> m;
    for (int i = 1 ; i <= n ; ++i)
    {
        std::cin >> t[i] + 1;
    }
}

void fastIO()
{
    std::ios_base :: sync_with_stdio(0);
    std::cout.tie(nullptr);
    std::cin.tie(nullptr);
}

int main ()
{
    fastIO();
    read();
    solve();

    return 0;
}

Compilation message (stderr)

joi2019_ho_t1.cpp: In function 'void read()':
joi2019_ho_t1.cpp:36:26: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   36 |         std::cin >> t[i] + 1;
      |                     ~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...