Submission #1001330

# Submission time Handle Problem Language Result Execution time Memory
1001330 2024-06-18T20:24:32 Z ivan_alexeev Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
142 ms 88716 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>


#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,bmi2,fma,popcnt")


#ifdef lisie_bimbi
#define debug(x) cout << #x << " : " << x << endl;
#else
#define debug(x) ;
#define endl '\n'
#endif

//#define int long long
#define inf 1000000000
#define double long double
typedef long long ll;

#ifdef lisie_bimbi
const int MAXC = 5;
#else
const int MAXC = 505;
#endif


signed main(){
#ifdef lisie_bimbi
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    int n, m;
    cin >> n >> m;
    vector<vector<char>> c(n, vector<char>(m));
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        for(int j = 0; j < m; j++){
            c[i][j] = s[j];
        }
    }
    vector<vector<int>> oo(n, vector<int>(m)), ii(n, vector<int>(m));
    for(int i = 0; i < n; i++){
        oo[i][m - 1] = (c[i][m - 1] == 'O');
        for(int j = m - 2; j >= 0; j--){
            oo[i][j] = oo[i][j + 1] + (c[i][j] == 'O');
        }
    }
    for(int j = 0; j < m; j++){
        ii[n - 1][j] = (c[n - 1][j] == 'I');
        for(int i = n - 2; i >= 0; i--){
            ii[i][j] = ii[i + 1][j] + (c[i][j] == 'I');
        }
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(c[i][j] == 'J') {
                ans += (ll) oo[i][j] * (ll) ii[i][j];
            }
        }
    }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 464 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 464 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 3 ms 2396 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 2 ms 1628 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 3 ms 2908 KB Output is correct
19 Correct 3 ms 2652 KB Output is correct
20 Correct 2 ms 2908 KB Output is correct
21 Correct 4 ms 2908 KB Output is correct
22 Correct 3 ms 2652 KB Output is correct
23 Correct 3 ms 2908 KB Output is correct
24 Correct 3 ms 2908 KB Output is correct
25 Correct 3 ms 2872 KB Output is correct
26 Correct 4 ms 2772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 464 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 3 ms 2396 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 2 ms 1628 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 3 ms 2908 KB Output is correct
19 Correct 3 ms 2652 KB Output is correct
20 Correct 2 ms 2908 KB Output is correct
21 Correct 4 ms 2908 KB Output is correct
22 Correct 3 ms 2652 KB Output is correct
23 Correct 3 ms 2908 KB Output is correct
24 Correct 3 ms 2908 KB Output is correct
25 Correct 3 ms 2872 KB Output is correct
26 Correct 4 ms 2772 KB Output is correct
27 Correct 142 ms 83796 KB Output is correct
28 Correct 1 ms 860 KB Output is correct
29 Correct 7 ms 6600 KB Output is correct
30 Correct 0 ms 604 KB Output is correct
31 Correct 93 ms 61908 KB Output is correct
32 Correct 125 ms 88032 KB Output is correct
33 Correct 125 ms 88656 KB Output is correct
34 Correct 111 ms 71764 KB Output is correct
35 Correct 133 ms 88148 KB Output is correct
36 Correct 129 ms 88400 KB Output is correct
37 Correct 142 ms 88716 KB Output is correct
38 Correct 78 ms 61268 KB Output is correct
39 Correct 70 ms 61664 KB Output is correct