Submission #589321

# Submission time Handle Problem Language Result Execution time Memory
589321 2022-07-04T12:55:38 Z MohamedFaresNebili Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
239 ms 158808 KB
#include <bits/stdc++.h>
/// #pragma GCC optimize ("Ofast")
/// #pragma GCC target ("avx2")
/// #pragma GCC optimize("unroll-loops")

                using namespace std;

                using ll = long long;
                using ld = long double;
                using ii = pair<ll, ll>;
                using vi = vector<int>;

                #define ff first
                #define ss second
                #define pb push_back
                #define all(x) (x).begin(), (x).end()
                #define lb lower_bound
                #define int ll
                #define double ld

                const int MOD = 1000 * 1000 * 1000 + 7;
                const double EPS = 1e-9;

                int H, W, A[3001][3001], B[3001][3001];
                char grid[3001][3001]; int DP[3001][3001][2];

                int32_t main() {
                    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
                    cin >> H >> W;
                    for(int l = 1; l <= H; l++)
                        for(int i = 1; i <= W; i++)
                            cin >> grid[l][i];
                    int res = 0;
                    for(int l = 1; l <= H; l++) {
                        for(int i = 1; i <= W; i++) {
                            DP[l][i][0] = (grid[l][i] == 'O');
                            DP[l][i][1] = (grid[l][i] == 'I');

                            DP[l][i][0] += DP[l - 1][i][0],
                            DP[l][i][1] += DP[l - 1][i][1];

                            DP[l][i][0] += DP[l][i - 1][0],
                            DP[l][i][1] += DP[l][i - 1][1];

                            DP[l][i][0] -= DP[l - 1][i - 1][0],
                            DP[l][i][1] -= DP[l - 1][i - 1][1];
                        }
                    }
                    for(int l = 1; l <= H; l++) {
                        for(int i = 1; i <= W; i++) {
                            if(grid[l][i] != 'J') continue;
                            int U = DP[l][W][0] - DP[l][i - 1][0] - DP[l - 1][W][0] + DP[l - 1][i - 1][0];
                            int V = DP[H][i][1] - DP[H][i - 1][1] - DP[l - 1][i][1] + DP[l - 1][i - 1][1];
                            res += U * V;
                        }
                    }
                    cout << res << "\n";
                    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 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 1108 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 3 ms 1108 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
12 Correct 1 ms 1108 KB Output is correct
13 Correct 1 ms 1108 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 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 1108 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 3 ms 1108 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
12 Correct 1 ms 1108 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
14 Correct 7 ms 6968 KB Output is correct
15 Correct 2 ms 3284 KB Output is correct
16 Correct 4 ms 4180 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 8 ms 7900 KB Output is correct
19 Correct 7 ms 7756 KB Output is correct
20 Correct 7 ms 7764 KB Output is correct
21 Correct 8 ms 7892 KB Output is correct
22 Correct 7 ms 7764 KB Output is correct
23 Correct 7 ms 7764 KB Output is correct
24 Correct 9 ms 7888 KB Output is correct
25 Correct 9 ms 7828 KB Output is correct
26 Correct 8 ms 7760 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 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 1108 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 3 ms 1108 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
12 Correct 1 ms 1108 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
14 Correct 7 ms 6968 KB Output is correct
15 Correct 2 ms 3284 KB Output is correct
16 Correct 4 ms 4180 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 8 ms 7900 KB Output is correct
19 Correct 7 ms 7756 KB Output is correct
20 Correct 7 ms 7764 KB Output is correct
21 Correct 8 ms 7892 KB Output is correct
22 Correct 7 ms 7764 KB Output is correct
23 Correct 7 ms 7764 KB Output is correct
24 Correct 9 ms 7888 KB Output is correct
25 Correct 9 ms 7828 KB Output is correct
26 Correct 8 ms 7760 KB Output is correct
27 Correct 203 ms 158280 KB Output is correct
28 Correct 7 ms 16980 KB Output is correct
29 Correct 15 ms 12884 KB Output is correct
30 Correct 1 ms 724 KB Output is correct
31 Correct 157 ms 121524 KB Output is correct
32 Correct 204 ms 158776 KB Output is correct
33 Correct 193 ms 158332 KB Output is correct
34 Correct 176 ms 141004 KB Output is correct
35 Correct 239 ms 158808 KB Output is correct
36 Correct 190 ms 158336 KB Output is correct
37 Correct 216 ms 158756 KB Output is correct
38 Correct 148 ms 120744 KB Output is correct
39 Correct 144 ms 121164 KB Output is correct