Submission #799673

# Submission time Handle Problem Language Result Execution time Memory
799673 2023-07-31T18:52:34 Z n3rm1n Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
344 ms 159104 KB
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const long long MAXN = 3005;
void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
long long n, m;
char a[MAXN][MAXN];
long long suffo[MAXN][MAXN], suffi[MAXN][MAXN];
void read_precompute()
{
    cin >> n >> m;
    for (long long i = 1; i <= n; ++ i)
    {
        for (long long j = 1; j <= m; ++ j)
            cin >> a[i][j];
    }
    for (long long i = 1; i <= n; ++ i)
    {
        for (long long j = m; j >= 1; -- j)
        {
            suffo[i][j] = suffo[i][j+1];
            if(a[i][j] == 'O')suffo[i][j] ++;
        }
    }
    for (long long j = 1; j <= m; ++ j)
    {
        for (long long i = n; i >= 1; -- i)
        {
            suffi[i][j] = suffi[i+1][j];
            if(a[i][j] == 'I')suffi[i][j] ++;
        }
    }
}
void solve()
{
    long long ans = 0;
    for (long long i = 1; i <= n; ++ i)
    {
        for (long long j = 1; j <= m; ++ j)
        {
            if(a[i][j] == 'J')ans += suffo[i][j] * suffi[i][j];
        }
    }
    cout << ans << endl;
}
int main()
{
    speed();

    read_precompute();
    solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 1616 KB Output is correct
6 Correct 1 ms 1492 KB Output is correct
7 Correct 1 ms 1492 KB Output is correct
8 Correct 1 ms 1492 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 1 ms 1364 KB Output is correct
11 Correct 1 ms 1492 KB Output is correct
12 Correct 1 ms 1492 KB Output is correct
13 Correct 1 ms 1364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 1616 KB Output is correct
6 Correct 1 ms 1492 KB Output is correct
7 Correct 1 ms 1492 KB Output is correct
8 Correct 1 ms 1492 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 1 ms 1364 KB Output is correct
11 Correct 1 ms 1492 KB Output is correct
12 Correct 1 ms 1492 KB Output is correct
13 Correct 1 ms 1364 KB Output is correct
14 Correct 7 ms 8916 KB Output is correct
15 Correct 2 ms 4948 KB Output is correct
16 Correct 4 ms 5332 KB Output is correct
17 Correct 1 ms 452 KB Output is correct
18 Correct 9 ms 9920 KB Output is correct
19 Correct 8 ms 9812 KB Output is correct
20 Correct 7 ms 9684 KB Output is correct
21 Correct 10 ms 9932 KB Output is correct
22 Correct 7 ms 9764 KB Output is correct
23 Correct 7 ms 9700 KB Output is correct
24 Correct 9 ms 9940 KB Output is correct
25 Correct 7 ms 9812 KB Output is correct
26 Correct 8 ms 9684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 1616 KB Output is correct
6 Correct 1 ms 1492 KB Output is correct
7 Correct 1 ms 1492 KB Output is correct
8 Correct 1 ms 1492 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 1 ms 1364 KB Output is correct
11 Correct 1 ms 1492 KB Output is correct
12 Correct 1 ms 1492 KB Output is correct
13 Correct 1 ms 1364 KB Output is correct
14 Correct 7 ms 8916 KB Output is correct
15 Correct 2 ms 4948 KB Output is correct
16 Correct 4 ms 5332 KB Output is correct
17 Correct 1 ms 452 KB Output is correct
18 Correct 9 ms 9920 KB Output is correct
19 Correct 8 ms 9812 KB Output is correct
20 Correct 7 ms 9684 KB Output is correct
21 Correct 10 ms 9932 KB Output is correct
22 Correct 7 ms 9764 KB Output is correct
23 Correct 7 ms 9700 KB Output is correct
24 Correct 9 ms 9940 KB Output is correct
25 Correct 7 ms 9812 KB Output is correct
26 Correct 8 ms 9684 KB Output is correct
27 Correct 317 ms 158600 KB Output is correct
28 Correct 10 ms 26348 KB Output is correct
29 Correct 15 ms 13908 KB Output is correct
30 Correct 1 ms 724 KB Output is correct
31 Correct 218 ms 131336 KB Output is correct
32 Correct 300 ms 159104 KB Output is correct
33 Correct 336 ms 158504 KB Output is correct
34 Correct 277 ms 152376 KB Output is correct
35 Correct 302 ms 158952 KB Output is correct
36 Correct 297 ms 158520 KB Output is correct
37 Correct 344 ms 159072 KB Output is correct
38 Correct 193 ms 130732 KB Output is correct
39 Correct 192 ms 130764 KB Output is correct