답안 #589882

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
589882 2022-07-05T11:16:42 Z boris_mihov Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
84 ms 88572 KB
#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

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;
      |                     ~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 1492 KB Output is correct
7 Correct 1 ms 1364 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
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 1492 KB Output is correct
7 Correct 1 ms 1364 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 4 ms 7508 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 3 ms 4436 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 5 ms 7936 KB Output is correct
19 Correct 5 ms 7892 KB Output is correct
20 Correct 5 ms 7900 KB Output is correct
21 Correct 5 ms 8028 KB Output is correct
22 Correct 5 ms 7892 KB Output is correct
23 Correct 4 ms 7892 KB Output is correct
24 Correct 6 ms 8004 KB Output is correct
25 Correct 7 ms 7936 KB Output is correct
26 Correct 7 ms 7892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 1492 KB Output is correct
7 Correct 1 ms 1364 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 4 ms 7508 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 3 ms 4436 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 5 ms 7936 KB Output is correct
19 Correct 5 ms 7892 KB Output is correct
20 Correct 5 ms 7900 KB Output is correct
21 Correct 5 ms 8028 KB Output is correct
22 Correct 5 ms 7892 KB Output is correct
23 Correct 4 ms 7892 KB Output is correct
24 Correct 6 ms 8004 KB Output is correct
25 Correct 7 ms 7936 KB Output is correct
26 Correct 7 ms 7892 KB Output is correct
27 Correct 76 ms 88084 KB Output is correct
28 Correct 12 ms 26056 KB Output is correct
29 Correct 6 ms 7752 KB Output is correct
30 Correct 1 ms 596 KB Output is correct
31 Correct 59 ms 72648 KB Output is correct
32 Correct 70 ms 88528 KB Output is correct
33 Correct 63 ms 88268 KB Output is correct
34 Correct 67 ms 84228 KB Output is correct
35 Correct 74 ms 88540 KB Output is correct
36 Correct 83 ms 88292 KB Output is correct
37 Correct 84 ms 88572 KB Output is correct
38 Correct 53 ms 72628 KB Output is correct
39 Correct 54 ms 72316 KB Output is correct