답안 #761860

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
761860 2023-06-20T10:34:26 Z sysia Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
353 ms 159440 KB
//Sylwia Sapkowska
#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
using namespace std;

void __print(int x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << "'" << x << "'";}
void __print(const char *x) {cerr << '"' << x << '"';}
void __print(const string &x) {cerr << '"' << x << '"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? ", " : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define int long long
typedef pair<int, int> T;
const int oo = 1e18, oo2 = 1e9+7, K = 30;
const int mod = 998244353;

void solve(){
    int n, m; cin >> n >> m;
    vector<vector<char>>a(n+1, vector<char>(m+1));
    for (int i = 1; i<=n; i++){
        for (int j = 1; j<=m; j++) {
            cin >> a[i][j];
        }
    }
    vector O(n+1, vector<int>(m+1));
    vector I(n+1, vector<int>(m+1));
    for (int i = 1; i<=n; i++){
        for (int j = m; j>=1; j--){
            if (j + 1 <= m) O[i][j] += O[i][j+1];
            if (a[i][j] == 'O') O[i][j]++;
        }
    }
    for (int j = 1; j<=m; j++){
        for (int i = n; i>=1; i--){
            if (i+1 <= n) I[i][j] += I[i+1][j];
            if (a[i][j] == 'I') I[i][j]++;
        }
    }
    int ans = 0;
    for (int i = 1; i<=n; i++){
        for (int j = 1; j<=m; j++){
            if (a[i][j] == 'J'){
                ans += O[i][j] * I[i][j];
            }
        }
    }
    cout << ans << "\n";
}

int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    //cin >> t;
    while (t--) solve();

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 456 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 456 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 456 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 456 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 6 ms 3668 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 4 ms 2516 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 7 ms 4756 KB Output is correct
19 Correct 6 ms 4552 KB Output is correct
20 Correct 6 ms 4688 KB Output is correct
21 Correct 7 ms 4692 KB Output is correct
22 Correct 6 ms 4524 KB Output is correct
23 Correct 5 ms 4692 KB Output is correct
24 Correct 7 ms 4692 KB Output is correct
25 Correct 6 ms 4564 KB Output is correct
26 Correct 5 ms 4652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 456 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 456 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 6 ms 3668 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 4 ms 2516 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 7 ms 4756 KB Output is correct
19 Correct 6 ms 4552 KB Output is correct
20 Correct 6 ms 4688 KB Output is correct
21 Correct 7 ms 4692 KB Output is correct
22 Correct 6 ms 4524 KB Output is correct
23 Correct 5 ms 4692 KB Output is correct
24 Correct 7 ms 4692 KB Output is correct
25 Correct 6 ms 4564 KB Output is correct
26 Correct 5 ms 4652 KB Output is correct
27 Correct 313 ms 150548 KB Output is correct
28 Correct 1 ms 980 KB Output is correct
29 Correct 16 ms 11696 KB Output is correct
30 Correct 1 ms 724 KB Output is correct
31 Correct 234 ms 110684 KB Output is correct
32 Correct 304 ms 158276 KB Output is correct
33 Correct 303 ms 158728 KB Output is correct
34 Correct 245 ms 128388 KB Output is correct
35 Correct 298 ms 158172 KB Output is correct
36 Correct 300 ms 158744 KB Output is correct
37 Correct 353 ms 159440 KB Output is correct
38 Correct 206 ms 109888 KB Output is correct
39 Correct 199 ms 110280 KB Output is correct