Submission #366554

# Submission time Handle Problem Language Result Execution time Memory
366554 2021-02-14T13:16:31 Z Tuk1352 Bitaro the Brave (JOI19_ho_t1) C++11
100 / 100
884 ms 88556 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, m, p;
    cin >> n >> m;
    char C[n][m];
    int H[n][m], R[n][m];
    for (int i = 0; i < n; i++)
    {
        for (int y = 0; y < m; y++)
        {
            cin >> C[i][y];
            H[i][y] = 0;
            R[i][y] = 0;
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int y = m-1; y >= 0; y--)
        {
            if (y == m-1)
            {
                R[i][y] = 0;
            }
            else
            {
                R[i][y] = R[i][y+1];
            }
            if (C[i][y] == 'O')
            {
                R[i][y]++;
            }
        }
    }
    for (int y = 0; y < m; y++)
    {
        for (int i = n-1; i >= 0; i--)
        {
            if (i == n-1)
            {
                H[i][y] = 0;
            }
            else
            {
                H[i][y] = H[i+1][y];
            }
            if (C[i][y] == 'I')
            {
                H[i][y]++;
            }
        }
    }
    long long S = 0;
    for (int i = 0; i < n; i++)
    {
        for (int y = 0; y < m; y++)
        {
            if (C[i][y] == 'J')
            {
                S += H[i][y] * R[i][y];
            }
        }
    }
    cout << S;
	return 0;
}

Compilation message

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:7:15: warning: unused variable 'p' [-Wunused-variable]
    7 |     int n, m, p;
      |               ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 19 ms 2284 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 10 ms 1516 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 24 ms 2924 KB Output is correct
19 Correct 18 ms 2668 KB Output is correct
20 Correct 22 ms 2668 KB Output is correct
21 Correct 25 ms 2796 KB Output is correct
22 Correct 21 ms 2652 KB Output is correct
23 Correct 19 ms 2668 KB Output is correct
24 Correct 21 ms 2796 KB Output is correct
25 Correct 18 ms 2668 KB Output is correct
26 Correct 18 ms 2668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 2 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 19 ms 2284 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 10 ms 1516 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 24 ms 2924 KB Output is correct
19 Correct 18 ms 2668 KB Output is correct
20 Correct 22 ms 2668 KB Output is correct
21 Correct 25 ms 2796 KB Output is correct
22 Correct 21 ms 2652 KB Output is correct
23 Correct 19 ms 2668 KB Output is correct
24 Correct 21 ms 2796 KB Output is correct
25 Correct 18 ms 2668 KB Output is correct
26 Correct 18 ms 2668 KB Output is correct
27 Correct 822 ms 83664 KB Output is correct
28 Correct 2 ms 620 KB Output is correct
29 Correct 48 ms 6640 KB Output is correct
30 Correct 2 ms 492 KB Output is correct
31 Correct 619 ms 61524 KB Output is correct
32 Correct 823 ms 87916 KB Output is correct
33 Correct 812 ms 88300 KB Output is correct
34 Correct 675 ms 71532 KB Output is correct
35 Correct 819 ms 87916 KB Output is correct
36 Correct 809 ms 88232 KB Output is correct
37 Correct 884 ms 88556 KB Output is correct
38 Correct 560 ms 61100 KB Output is correct
39 Correct 549 ms 61292 KB Output is correct