답안 #879964

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
879964 2023-11-28T12:07:34 Z amin_2008 Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
218 ms 171200 KB
#pragma GCC optimize ("O3")
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

// author: amin_2008

#define ios          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll           long long
#define vi           vector<int>
#define vs           vector<string>
#define vc           vector<char>
#define vl           vector<ll>
#define all(v)       v.begin(), v.end()
#define rall(v)      v.rbegin(), v.rend()
#define pb           push_back
#define bpc          __builtin_popcount
#define pii          pair<int, int>
#define pll          pair<ll, ll>
#define piii         pair<pii, int>
#define vpii         vector<pii>
#define vpll         vector<pll>
#define vvpii        vector<vpii>
#define vvi          vector<vector<int>>
#define vvl          vector<vector<ll>>
#define ins          insert
#define ts           to_string
#define F            first
#define S            second
#define lb           lower_bound
#define ub           upper_bound
#define ld           long double
#define ull          unsigned long long
#define endl         '\n'
#define int          ll

using namespace std;
using namespace __gnu_pbds;
using namespace __cxx11;
template<class T> using ordered_set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int inf = 1e18;
const int mod = 1e9+7;
const int sz = 2e5+5;
const int N = 100005;
const int logg = 18;
const int P = 40000005;
const int M = 5e5+5;

//int a[sz];
char a[3005][3005];

void solve()
{
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            cin >> a[i][j];
    vvi v(n, vi (1, 0)), p(1, vi (m, 0));
    for(int i = 0; i < n; i++)
    {
        vi vv;
        for(int j = 0; j < m; j++)
            v[i].pb(v[i].back() + ( a[i][j] == 'O' )),
            vv.pb(p.back()[j] + ( a[i][j] == 'I' ));
        p.pb(vv);
    }
    int res = 0;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            if ( a[i][j] == 'J' )
                res += ( v[i][m] - v[i][j] ) * ( p[n][j] - p[i][j] );
    cout << res << endl;
}

signed main()
{
    ios;
    //precompute();
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2776 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
13 Correct 1 ms 2780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2776 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
13 Correct 1 ms 2780 KB Output is correct
14 Correct 5 ms 6236 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 3 ms 4840 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 6 ms 6748 KB Output is correct
19 Correct 5 ms 6748 KB Output is correct
20 Correct 5 ms 6748 KB Output is correct
21 Correct 7 ms 6748 KB Output is correct
22 Correct 6 ms 6744 KB Output is correct
23 Correct 5 ms 6748 KB Output is correct
24 Correct 6 ms 6748 KB Output is correct
25 Correct 5 ms 6744 KB Output is correct
26 Correct 5 ms 6884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2776 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2652 KB Output is correct
13 Correct 1 ms 2780 KB Output is correct
14 Correct 5 ms 6236 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 3 ms 4840 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 6 ms 6748 KB Output is correct
19 Correct 5 ms 6748 KB Output is correct
20 Correct 5 ms 6748 KB Output is correct
21 Correct 7 ms 6748 KB Output is correct
22 Correct 6 ms 6744 KB Output is correct
23 Correct 5 ms 6748 KB Output is correct
24 Correct 6 ms 6748 KB Output is correct
25 Correct 5 ms 6744 KB Output is correct
26 Correct 5 ms 6884 KB Output is correct
27 Correct 192 ms 162788 KB Output is correct
28 Correct 2 ms 9308 KB Output is correct
29 Correct 16 ms 14496 KB Output is correct
30 Correct 1 ms 860 KB Output is correct
31 Correct 141 ms 123040 KB Output is correct
32 Correct 183 ms 170452 KB Output is correct
33 Correct 177 ms 170836 KB Output is correct
34 Correct 161 ms 141392 KB Output is correct
35 Correct 181 ms 170208 KB Output is correct
36 Correct 180 ms 170836 KB Output is correct
37 Correct 218 ms 171200 KB Output is correct
38 Correct 128 ms 122100 KB Output is correct
39 Correct 124 ms 122608 KB Output is correct