Submission #391198

# Submission time Handle Problem Language Result Execution time Memory
391198 2021-04-18T08:06:09 Z Aryan_Raina Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
155 ms 159780 KB
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define ld long double
#define ar array
 
const int INF = 1e17;
const int MOD = 998244353;

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m; cin>>n>>m;
    string s[n];
    for (auto &i : s) cin>>i;
    int sfO[n][m], sfI[n][m];
    int ans = 0;
    for (int i = n-1; i >= 0; --i) {
        for (int j = m-1; j >= 0; --j) {
            sfO[i][j] = (j+1 < m) ? sfO[i][j+1] : 0;
            sfI[i][j] = (i+1 < n) ? sfI[i+1][j] : 0;
            if (s[i][j] == 'J') ans += sfO[i][j]*sfI[i][j]; 
            if (s[i][j] == 'O') sfO[i][j] = 1 + ((j+1 < m) ? sfO[i][j+1] : 0);
            if (s[i][j] == 'I') sfI[i][j] = 1 + ((i+1 < n) ? sfI[i+1][j] : 0);
        } 
    }
    cout<<ans<<"\n";
} 
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 3 ms 460 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 3 ms 460 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 4 ms 3660 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 2 ms 2508 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 5 ms 4684 KB Output is correct
19 Correct 4 ms 4556 KB Output is correct
20 Correct 4 ms 4556 KB Output is correct
21 Correct 5 ms 4688 KB Output is correct
22 Correct 4 ms 4556 KB Output is correct
23 Correct 5 ms 4556 KB Output is correct
24 Correct 5 ms 4684 KB Output is correct
25 Correct 4 ms 4544 KB Output is correct
26 Correct 4 ms 4556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 3 ms 460 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 4 ms 3660 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 2 ms 2508 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 5 ms 4684 KB Output is correct
19 Correct 4 ms 4556 KB Output is correct
20 Correct 4 ms 4556 KB Output is correct
21 Correct 5 ms 4688 KB Output is correct
22 Correct 4 ms 4556 KB Output is correct
23 Correct 5 ms 4556 KB Output is correct
24 Correct 5 ms 4684 KB Output is correct
25 Correct 4 ms 4544 KB Output is correct
26 Correct 4 ms 4556 KB Output is correct
27 Correct 155 ms 150872 KB Output is correct
28 Correct 1 ms 716 KB Output is correct
29 Correct 9 ms 11736 KB Output is correct
30 Correct 1 ms 720 KB Output is correct
31 Correct 115 ms 110916 KB Output is correct
32 Correct 106 ms 158660 KB Output is correct
33 Correct 108 ms 159280 KB Output is correct
34 Correct 140 ms 128684 KB Output is correct
35 Correct 112 ms 158672 KB Output is correct
36 Correct 105 ms 159196 KB Output is correct
37 Correct 154 ms 159780 KB Output is correct
38 Correct 74 ms 110028 KB Output is correct
39 Correct 73 ms 110572 KB Output is correct