Submission #968450

# Submission time Handle Problem Language Result Execution time Memory
968450 2024-04-23T12:39:06 Z tset Bitaro the Brave (JOI19_ho_t1) C++14
0 / 100
1 ms 348 KB
#include<bits/stdc++.h>

using namespace std;

#define int long long

signed main()
{
    int nbLigs, nbCols;
    cin >> nbLigs >> nbCols;
    vector<string> tab(nbLigs);
    for(int iL =0; iL < nbLigs; iL++)
    {
        cin >>tab[iL];
    }
    vector<vector<int>>cumulBotToTop(nbLigs+1, vector<int>(nbCols+1, 0));
    vector<vector<int>>cumulRightToLeft(nbLigs+1, vector<int>(nbCols+1, 0));
    for(int iL = nbLigs-1; iL >=0; iL--)
    {
        for(int iC = nbCols-1; iC >= 0; iC--)
        {
            cumulRightToLeft[iL][iC] = cumulRightToLeft[iL][iC+1];
            if(tab[iL][iC] == 'O')
                cumulRightToLeft[iL][iC]++;
        }
    }
    for(int iC = nbCols-1; iC >= 0; iC--)
    {
        for(int iL = nbLigs-1; iL >=0; iL--)
        {
            cumulBotToTop[iL][iC] = cumulBotToTop[iL+1][iC];
            if(tab[iL][iC] == 'I')
                cumulBotToTop[iL][iC]++;
        }
    }
    int ans = 0;
    for(int iL = 0; iL < nbLigs; iL++)
    {
        for(int iC = 0; iC < nbCols; iC++)
        {
            if(tab[iL][iC] == 'J')
            {
                ans += cumulBotToTop[iL][iC] * cumulBotToTop[iL][iC];
            }
        }
    }
    printf("%lld\n", ans);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -