Submission #985667

# Submission time Handle Problem Language Result Execution time Memory
985667 2024-05-18T13:47:10 Z vyshniak_n Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
156 ms 159896 KB
//#pragma optimize("Ofast")
//#pragma optimize("unroll-loops")
//#pragma traget("avx,avx2")

#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#include <cstdint>
#include <cstring>
#include <string>
#include <cstdlib>
#include <vector>
#include <bitset>
#include <map>
#include <queue>
#include <ctime>
#include <stack>
#include <set>
#include <list>
#include <random>
#include <deque>
#include <functional>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <complex>
#include <numeric>
#include <cassert>
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <thread>

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define el '\n'
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define point pair <ll, ll>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

#include <random>
mt19937 rnd(time(0));

const ll INF = 1e18 + 10;
const ll inf = 1e9 + 10;
const ll N = 3e3 + 10;
const ll mod = 1e9 + 7;
const ll K = 200;
const ll LOG = 8;

char a[N][N];
ll pref[N][N][2];

void solve() {
    ll h, w;
    cin >> h >> w;

    for (ll i = 1; i <= h; i++)
        for (ll j = 1; j <= w; j++)
            cin >> a[i][j];

    for (ll i = 1; i <= h; i++)
        for (ll j = 1; j <= w; j++)
            pref[i][j][0] = pref[i][j - 1][0] + (a[i][j] == 'O');
    for (ll i = 1; i <= h; i++)
        for (ll j = 1; j <= w; j++)
            pref[i][j][1] = pref[i - 1][j][1] + (a[i][j] == 'I');

    ll ans = 0;
    for (ll i = 1; i <= h; i++) {
        for (ll j = 1; j <= w; j++) {
            if (a[i][j] != 'J')
                continue;

            ans += (pref[i][w][0] - pref[i][j][0]) * (pref[h][j][1] - pref[i][j][1]);
        }
    }

    cout << ans << el;
    return;
}
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int tests = 1;
    //cin >> tests;

    while (tests--) 
        solve();
    return 0;
}
/*
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2904 KB Output is correct
6 Correct 1 ms 2908 KB Output is correct
7 Correct 1 ms 2904 KB Output is correct
8 Correct 1 ms 2908 KB Output is correct
9 Correct 1 ms 2908 KB Output is correct
10 Correct 1 ms 2908 KB Output is correct
11 Correct 1 ms 3032 KB Output is correct
12 Correct 1 ms 2908 KB Output is correct
13 Correct 1 ms 2908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2904 KB Output is correct
6 Correct 1 ms 2908 KB Output is correct
7 Correct 1 ms 2904 KB Output is correct
8 Correct 1 ms 2908 KB Output is correct
9 Correct 1 ms 2908 KB Output is correct
10 Correct 1 ms 2908 KB Output is correct
11 Correct 1 ms 3032 KB Output is correct
12 Correct 1 ms 2908 KB Output is correct
13 Correct 1 ms 2908 KB Output is correct
14 Correct 6 ms 9308 KB Output is correct
15 Correct 1 ms 4188 KB Output is correct
16 Correct 3 ms 7260 KB Output is correct
17 Correct 1 ms 2516 KB Output is correct
18 Correct 7 ms 11612 KB Output is correct
19 Correct 6 ms 11612 KB Output is correct
20 Correct 9 ms 11608 KB Output is correct
21 Correct 7 ms 11608 KB Output is correct
22 Correct 6 ms 11608 KB Output is correct
23 Correct 6 ms 11612 KB Output is correct
24 Correct 7 ms 11608 KB Output is correct
25 Correct 7 ms 11612 KB Output is correct
26 Correct 8 ms 11672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2904 KB Output is correct
6 Correct 1 ms 2908 KB Output is correct
7 Correct 1 ms 2904 KB Output is correct
8 Correct 1 ms 2908 KB Output is correct
9 Correct 1 ms 2908 KB Output is correct
10 Correct 1 ms 2908 KB Output is correct
11 Correct 1 ms 3032 KB Output is correct
12 Correct 1 ms 2908 KB Output is correct
13 Correct 1 ms 2908 KB Output is correct
14 Correct 6 ms 9308 KB Output is correct
15 Correct 1 ms 4188 KB Output is correct
16 Correct 3 ms 7260 KB Output is correct
17 Correct 1 ms 2516 KB Output is correct
18 Correct 7 ms 11612 KB Output is correct
19 Correct 6 ms 11612 KB Output is correct
20 Correct 9 ms 11608 KB Output is correct
21 Correct 7 ms 11608 KB Output is correct
22 Correct 6 ms 11608 KB Output is correct
23 Correct 6 ms 11612 KB Output is correct
24 Correct 7 ms 11608 KB Output is correct
25 Correct 7 ms 11612 KB Output is correct
26 Correct 8 ms 11672 KB Output is correct
27 Correct 154 ms 158936 KB Output is correct
28 Correct 6 ms 18524 KB Output is correct
29 Correct 11 ms 15180 KB Output is correct
30 Correct 1 ms 2904 KB Output is correct
31 Correct 130 ms 130500 KB Output is correct
32 Correct 138 ms 159832 KB Output is correct
33 Correct 139 ms 159824 KB Output is correct
34 Correct 134 ms 150724 KB Output is correct
35 Correct 135 ms 159800 KB Output is correct
36 Correct 135 ms 159820 KB Output is correct
37 Correct 156 ms 159896 KB Output is correct
38 Correct 109 ms 130368 KB Output is correct
39 Correct 100 ms 130076 KB Output is correct