Submission #542007

# Submission time Handle Problem Language Result Execution time Memory
542007 2022-03-25T06:28:21 Z Cookie197 Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
328 ms 114964 KB
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>

using namespace std;
#define ll long long
#define endl "\n"
#define mp make_pair
#define out(x) cout<< #x << " = " << x << endl
#define pii pair<int,int> 
#pragma GCC optimize("Ofast")

int n,m;
int arr[3005][3005];
int Opre[3005][3005], Ipre[3005][3005];
signed main(){
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n>>m;
    for (int i=1;i<=n;i++) for (int j=1;j<=m;j++){
        char c; cin>>c;
        if (c=='J') arr[i][j] = 0;
        if (c=='O') arr[i][j] = 1;
        if (c=='I') arr[i][j] = 2;
    }

    for (int i=1;i<=n;i++) for (int j=1;j<=m;j++) Opre[i][j] = Opre[i][j-1] + (arr[i][j] == 1);
    for (int j=1;j<=m;j++) for (int i=1;i<=n;i++) Ipre[i][j] = Ipre[i-1][j] + (arr[i][j] == 2);
        
    
    ll ans = 0;
    for (int i=1;i<=n;i++) for (int j=1;j<=m;j++) if (arr[i][j] == 0){
        int x = Opre[i][m] - Opre[i][j];
        int y = Ipre[n][j] - Ipre[i][j];
        ans += 1ll * x * y;
    }
    cout<<ans<<endl;
}
# 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 328 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 1620 KB Output is correct
6 Correct 1 ms 1620 KB Output is correct
7 Correct 1 ms 1488 KB Output is correct
8 Correct 1 ms 1620 KB Output is correct
9 Correct 1 ms 1612 KB Output is correct
10 Correct 1 ms 1492 KB Output is correct
11 Correct 1 ms 1616 KB Output is correct
12 Correct 1 ms 1620 KB Output is correct
13 Correct 1 ms 1492 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 328 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 1620 KB Output is correct
6 Correct 1 ms 1620 KB Output is correct
7 Correct 1 ms 1488 KB Output is correct
8 Correct 1 ms 1620 KB Output is correct
9 Correct 1 ms 1612 KB Output is correct
10 Correct 1 ms 1492 KB Output is correct
11 Correct 1 ms 1616 KB Output is correct
12 Correct 1 ms 1620 KB Output is correct
13 Correct 1 ms 1492 KB Output is correct
14 Correct 11 ms 8704 KB Output is correct
15 Correct 3 ms 5460 KB Output is correct
16 Correct 5 ms 5076 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 12 ms 9492 KB Output is correct
19 Correct 10 ms 9380 KB Output is correct
20 Correct 8 ms 9300 KB Output is correct
21 Correct 12 ms 9412 KB Output is correct
22 Correct 10 ms 9360 KB Output is correct
23 Correct 8 ms 9268 KB Output is correct
24 Correct 11 ms 9476 KB Output is correct
25 Correct 9 ms 9416 KB Output is correct
26 Correct 8 ms 9300 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 328 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 1620 KB Output is correct
6 Correct 1 ms 1620 KB Output is correct
7 Correct 1 ms 1488 KB Output is correct
8 Correct 1 ms 1620 KB Output is correct
9 Correct 1 ms 1612 KB Output is correct
10 Correct 1 ms 1492 KB Output is correct
11 Correct 1 ms 1616 KB Output is correct
12 Correct 1 ms 1620 KB Output is correct
13 Correct 1 ms 1492 KB Output is correct
14 Correct 11 ms 8704 KB Output is correct
15 Correct 3 ms 5460 KB Output is correct
16 Correct 5 ms 5076 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 12 ms 9492 KB Output is correct
19 Correct 10 ms 9380 KB Output is correct
20 Correct 8 ms 9300 KB Output is correct
21 Correct 12 ms 9412 KB Output is correct
22 Correct 10 ms 9360 KB Output is correct
23 Correct 8 ms 9268 KB Output is correct
24 Correct 11 ms 9476 KB Output is correct
25 Correct 9 ms 9416 KB Output is correct
26 Correct 8 ms 9300 KB Output is correct
27 Correct 315 ms 114524 KB Output is correct
28 Correct 13 ms 28620 KB Output is correct
29 Correct 14 ms 10084 KB Output is correct
30 Correct 2 ms 588 KB Output is correct
31 Correct 234 ms 94536 KB Output is correct
32 Correct 255 ms 114908 KB Output is correct
33 Correct 215 ms 114508 KB Output is correct
34 Correct 266 ms 109700 KB Output is correct
35 Correct 261 ms 114880 KB Output is correct
36 Correct 223 ms 114524 KB Output is correct
37 Correct 328 ms 114964 KB Output is correct
38 Correct 172 ms 94540 KB Output is correct
39 Correct 157 ms 94252 KB Output is correct