Submission #1093681

# Submission time Handle Problem Language Result Execution time Memory
1093681 2024-09-27T08:56:40 Z lamagril Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
205 ms 159056 KB
#include <bits/stdc++.h>
#define int long long

using namespace std;

const int nx=3005;

char mp[nx][nx];
int qso[nx][nx];
int qsi[nx][nx];

int32_t main(){
    cin.tie(NULL)->sync_with_stdio(false);
    int n,m; cin >> n >> m;
    for(int i=1 ; i<=n ; i++){
        string s; cin >> s;
        for(int j=1 ; j<=m ; j++){
            mp[i][j]=s[j-1];
        }
    }
    for(int i=1 ; i<=n ; i++){
        for(int j=m ; j>=1 ; j--){
            if(mp[i][j]=='O'){
                qso[i][j]=qso[i][j+1]+1;
            }
            else{
                qso[i][j]=qso[i][j+1];
            }
        }
    }
    for(int i=1 ; i<=m ; i++){
        for(int j=n ; j>=1 ; j--){
            if(mp[j][i]=='I'){
                qsi[j][i]=qsi[j+1][i]+1;
            }
            else{
                qsi[j][i]=qsi[j+1][i];
            }
        }
    }
    int ans=0;
    /*for(int i=1 ; i<=n ; i++){
        for(int j=1 ; j<=m ; j++){
            cout << qso[i][j] << ' ';
        }
        cout << '\n';
    }

    for(int i=1 ; i<=n ; i++){
        for(int j=1 ; j<=m ; j++){
            cout << qsi[i][j] << ' ';
        }
        cout << '\n';
    }*/
    for(int i=1 ; i<=n ; i++){
        for(int j=1 ; j<=m ; j++){
            if(mp[i][j]=='J'){
                ans+=qso[i][j]*qsi[i][j];
            }
        }
    }
    /* i j k l
    J = i j
    O = i l
    I = k j
    i<k
    j<l
    */
    cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 352 KB Output is correct
2 Correct 0 ms 352 KB Output is correct
3 Correct 0 ms 352 KB Output is correct
4 Correct 0 ms 352 KB Output is correct
5 Correct 1 ms 1628 KB Output is correct
6 Correct 1 ms 1632 KB Output is correct
7 Correct 1 ms 1428 KB Output is correct
8 Correct 1 ms 1636 KB Output is correct
9 Correct 1 ms 1640 KB Output is correct
10 Correct 1 ms 1376 KB Output is correct
11 Correct 1 ms 1628 KB Output is correct
12 Correct 1 ms 1632 KB Output is correct
13 Correct 1 ms 1372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 352 KB Output is correct
2 Correct 0 ms 352 KB Output is correct
3 Correct 0 ms 352 KB Output is correct
4 Correct 0 ms 352 KB Output is correct
5 Correct 1 ms 1628 KB Output is correct
6 Correct 1 ms 1632 KB Output is correct
7 Correct 1 ms 1428 KB Output is correct
8 Correct 1 ms 1636 KB Output is correct
9 Correct 1 ms 1640 KB Output is correct
10 Correct 1 ms 1376 KB Output is correct
11 Correct 1 ms 1628 KB Output is correct
12 Correct 1 ms 1632 KB Output is correct
13 Correct 1 ms 1372 KB Output is correct
14 Correct 6 ms 9056 KB Output is correct
15 Correct 2 ms 4952 KB Output is correct
16 Correct 3 ms 5452 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 6 ms 10076 KB Output is correct
19 Correct 6 ms 9824 KB Output is correct
20 Correct 6 ms 9816 KB Output is correct
21 Correct 7 ms 10076 KB Output is correct
22 Correct 6 ms 9976 KB Output is correct
23 Correct 5 ms 9820 KB Output is correct
24 Correct 6 ms 10032 KB Output is correct
25 Correct 6 ms 9820 KB Output is correct
26 Correct 6 ms 9944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 352 KB Output is correct
2 Correct 0 ms 352 KB Output is correct
3 Correct 0 ms 352 KB Output is correct
4 Correct 0 ms 352 KB Output is correct
5 Correct 1 ms 1628 KB Output is correct
6 Correct 1 ms 1632 KB Output is correct
7 Correct 1 ms 1428 KB Output is correct
8 Correct 1 ms 1636 KB Output is correct
9 Correct 1 ms 1640 KB Output is correct
10 Correct 1 ms 1376 KB Output is correct
11 Correct 1 ms 1628 KB Output is correct
12 Correct 1 ms 1632 KB Output is correct
13 Correct 1 ms 1372 KB Output is correct
14 Correct 6 ms 9056 KB Output is correct
15 Correct 2 ms 4952 KB Output is correct
16 Correct 3 ms 5452 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 6 ms 10076 KB Output is correct
19 Correct 6 ms 9824 KB Output is correct
20 Correct 6 ms 9816 KB Output is correct
21 Correct 7 ms 10076 KB Output is correct
22 Correct 6 ms 9976 KB Output is correct
23 Correct 5 ms 9820 KB Output is correct
24 Correct 6 ms 10032 KB Output is correct
25 Correct 6 ms 9820 KB Output is correct
26 Correct 6 ms 9944 KB Output is correct
27 Correct 182 ms 158544 KB Output is correct
28 Correct 12 ms 26460 KB Output is correct
29 Correct 10 ms 13880 KB Output is correct
30 Correct 1 ms 860 KB Output is correct
31 Correct 145 ms 131560 KB Output is correct
32 Correct 172 ms 158980 KB Output is correct
33 Correct 176 ms 158520 KB Output is correct
34 Correct 165 ms 152400 KB Output is correct
35 Correct 174 ms 159056 KB Output is correct
36 Correct 174 ms 158696 KB Output is correct
37 Correct 205 ms 159056 KB Output is correct
38 Correct 129 ms 130900 KB Output is correct
39 Correct 129 ms 130856 KB Output is correct