Submission #693963

# Submission time Handle Problem Language Result Execution time Memory
693963 2023-02-03T13:10:45 Z Gital Bitaro the Brave (JOI19_ho_t1) C++11
100 / 100
213 ms 116936 KB
#include<bits/stdc++.h>
using namespace std;
#define endl '\n';
typedef long long ll;
int H,W;
ll ans = 0;
vector<pair<int,int>> J;
int dpI[3003][3003];
int dpO[3003][3003];
string S[3003];
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> H >> W;
    for(int i = 1; i <= H; i++) {
        string s; cin >> s;
        S[i] = s;
    }
    for(int i = H; i >= 1; i--) {
        for(int j = W-1; j >= 0; j--) {
            dpI[j][i-1] += dpI[j][i];
            dpO[i][j-1] += dpO[i][j];
            if(S[i][j] == 'J') {
                J.push_back({i,j});
            }
            else if(S[i][j] == 'I') {
                dpI[j][i-1] += 1;
            }
            else if(S[i][j] == 'O') {
                dpO[i][j-1] += 1;
            }
        }
    }
    for(auto e : J) {
        int i = e.first;
        int j = e.second;
        //cout << endl;
        //cout << "i = "<< i << " j = " << j << endl;
        //cout << dpI[j][i] << " " << dpO[i][j] << endl;
        ans += (dpI[j][i] * dpO[i][j]);
        //cout << ans << endl
    }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 1328 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1236 KB Output is correct
8 Correct 2 ms 1324 KB Output is correct
9 Correct 2 ms 1236 KB Output is correct
10 Correct 1 ms 1236 KB Output is correct
11 Correct 1 ms 1364 KB Output is correct
12 Correct 1 ms 1236 KB Output is correct
13 Correct 1 ms 1324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 1328 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1236 KB Output is correct
8 Correct 2 ms 1324 KB Output is correct
9 Correct 2 ms 1236 KB Output is correct
10 Correct 1 ms 1236 KB Output is correct
11 Correct 1 ms 1364 KB Output is correct
12 Correct 1 ms 1236 KB Output is correct
13 Correct 1 ms 1324 KB Output is correct
14 Correct 7 ms 6348 KB Output is correct
15 Correct 1 ms 2132 KB Output is correct
16 Correct 5 ms 5264 KB Output is correct
17 Correct 1 ms 1572 KB Output is correct
18 Correct 10 ms 7592 KB Output is correct
19 Correct 7 ms 6960 KB Output is correct
20 Correct 7 ms 7532 KB Output is correct
21 Correct 8 ms 7632 KB Output is correct
22 Correct 8 ms 7436 KB Output is correct
23 Correct 7 ms 7504 KB Output is correct
24 Correct 8 ms 7760 KB Output is correct
25 Correct 6 ms 6996 KB Output is correct
26 Correct 9 ms 7532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 1328 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1236 KB Output is correct
8 Correct 2 ms 1324 KB Output is correct
9 Correct 2 ms 1236 KB Output is correct
10 Correct 1 ms 1236 KB Output is correct
11 Correct 1 ms 1364 KB Output is correct
12 Correct 1 ms 1236 KB Output is correct
13 Correct 1 ms 1324 KB Output is correct
14 Correct 7 ms 6348 KB Output is correct
15 Correct 1 ms 2132 KB Output is correct
16 Correct 5 ms 5264 KB Output is correct
17 Correct 1 ms 1572 KB Output is correct
18 Correct 10 ms 7592 KB Output is correct
19 Correct 7 ms 6960 KB Output is correct
20 Correct 7 ms 7532 KB Output is correct
21 Correct 8 ms 7632 KB Output is correct
22 Correct 8 ms 7436 KB Output is correct
23 Correct 7 ms 7504 KB Output is correct
24 Correct 8 ms 7760 KB Output is correct
25 Correct 6 ms 6996 KB Output is correct
26 Correct 9 ms 7532 KB Output is correct
27 Correct 210 ms 109804 KB Output is correct
28 Correct 6 ms 10168 KB Output is correct
29 Correct 23 ms 19224 KB Output is correct
30 Correct 6 ms 9940 KB Output is correct
31 Correct 177 ms 87648 KB Output is correct
32 Correct 161 ms 95016 KB Output is correct
33 Correct 213 ms 114396 KB Output is correct
34 Correct 178 ms 107060 KB Output is correct
35 Correct 193 ms 111444 KB Output is correct
36 Correct 209 ms 114344 KB Output is correct
37 Correct 212 ms 116936 KB Output is correct
38 Correct 118 ms 76244 KB Output is correct
39 Correct 136 ms 87728 KB Output is correct