답안 #915414

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
915414 2024-01-23T20:14:31 Z HorizonWest Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
216 ms 159680 KB
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define db double
#define ll __int128
#define int long long
#define pb push_back
#define fs first
#define sd second
#define Mod long(1e9 + 7)
#define all(x) x.begin(), x.end()
#define unvisited long(-1)
#define Eps double(1e-9)
#define _for(i, n) for(int i = 0; i < (n); i++)
#define dbg(x) cout << #x ": " << x << endl;

const int Max = 1e6 + 7, Inf = 1e9 + 7;

void print(bool x) { cout << (x ? "YES" : "NO") << endl; }

string tostring (__int128 x)
{
    string ans = "";
    while(x > 0)
    {
        ans += (x % 10 + '0');
        x /= 10;
    }
    reverse(all(ans));
    return ans;
}

void solve()
{
    int n, m; cin >> n >> m; 
    vector <vector<char>> c(n, vector <char> (m));
    for(auto& u : c) for(auto& j : u) cin >> j; 

    vector <vector<int>> s1(n + 2, vector <int> (m + 2)),
            s2(n + 2, vector <int> (m + 2));

    for(int i = n-1; i >= 0; i--)
    {
        for(int j = m-1; j >= 0; j--)
            s1[i][j] = s1[i][j+1] + (c[i][j] == 'O');
        
        for(int j = m-1; j >= 0; j--)
            s2[i][j] = s2[i+1][j] + (c[i][j] == 'I');
    }

    int ans = 0;

    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < m; j++) if(c[i][j] == 'J')
        {
            ans += s1[i][j] * s2[i][j];
        }
    }

    cout << ans << endl;
}

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

    int Q = 1; //cin >> Q;

    while (Q--)
    {
        solve();
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 452 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 460 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 452 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 460 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 6 ms 3676 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 3 ms 2652 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 6 ms 4700 KB Output is correct
19 Correct 5 ms 4696 KB Output is correct
20 Correct 5 ms 4864 KB Output is correct
21 Correct 6 ms 4700 KB Output is correct
22 Correct 5 ms 4700 KB Output is correct
23 Correct 5 ms 4700 KB Output is correct
24 Correct 7 ms 4700 KB Output is correct
25 Correct 5 ms 4568 KB Output is correct
26 Correct 5 ms 4700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 452 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 460 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 6 ms 3676 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 3 ms 2652 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 6 ms 4700 KB Output is correct
19 Correct 5 ms 4696 KB Output is correct
20 Correct 5 ms 4864 KB Output is correct
21 Correct 6 ms 4700 KB Output is correct
22 Correct 5 ms 4700 KB Output is correct
23 Correct 5 ms 4700 KB Output is correct
24 Correct 7 ms 4700 KB Output is correct
25 Correct 5 ms 4568 KB Output is correct
26 Correct 5 ms 4700 KB Output is correct
27 Correct 191 ms 150420 KB Output is correct
28 Correct 1 ms 1112 KB Output is correct
29 Correct 14 ms 11828 KB Output is correct
30 Correct 1 ms 860 KB Output is correct
31 Correct 151 ms 110948 KB Output is correct
32 Correct 192 ms 158284 KB Output is correct
33 Correct 184 ms 158796 KB Output is correct
34 Correct 168 ms 128448 KB Output is correct
35 Correct 182 ms 158548 KB Output is correct
36 Correct 180 ms 158940 KB Output is correct
37 Correct 216 ms 159680 KB Output is correct
38 Correct 130 ms 109904 KB Output is correct
39 Correct 131 ms 110520 KB Output is correct