Submission #416600

# Submission time Handle Problem Language Result Execution time Memory
416600 2021-06-02T16:52:55 Z ioi Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
412 ms 159748 KB
#include<bits/stdc++.h>
/*
Created By Tornado2004
*/
using namespace std;

#define debug(x) cout << '[' << #x << " is: " << x << "] " << endl;
#define imod(a , n) (a % n + n ) % n

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define inF freopen("ladder.in","r",stdin );
#define outF freopen("ladder.out" , "w" , stdout ) ;
#define sor(v) sort(v.begin() , v.end());
#define print(v) for(auto f : v ) cout << f << " " ;
#define rsor(v) sort(v.rbegin() , v.rend());
#define rev(v) reverse(v.begin() , v.end());
#define scan(v)for(auto &it : v)cin >> it ;

#define ll long long
#define int ll
#define logar(x , y) log(x) / log(y)
#define __sum(n) n * (n + 1) / 2
#define __lcm(a , b) a / __gcd(a , b) * b
#define pii pair<int , int >
const int N = 2e5 + 3 , K = 11 , M = N * 4 ;
const ll MOD = 998244353 , oo = 1e9 , OO = 1e18 , mod = MOD ;
const double pi = acos(-1) , eps = 1e-17 ;

//37
// (a ^ b / c ) % mod = (a ^ b ) % MOD * (c ^ (mod - 2)) % mod
// m is prime --> (a ^ m) % m = a % m

int di[] = {0 , 0 , 1 , -1};
int dj[] = {1 , -1 , 0 , 0};





int32_t main()
{   //inF;
    //inF;outF;
    fastio;




    int n , m ;
    cin >> n >> m ;
    ll ans = 0 ;

    char arr[n][m];

    for(int i = 0 ; i < n ; i ++)
        for(int j = 0 ; j < m ; j ++)
            cin >> arr[i][j];

    int cumi[n + 10][m + 10] = {} , cumo[n + 10][m + 10] = {};

    for(int j = 0 ;j < m ; j++){

        int sum = 0 ;
        for(int i = n - 1 ; i >= 0 ; i -- ){
            if(arr[i][j] == 'I')sum ++ ;
            cumi [i][j] = sum ;
        }
    }

    for(int i = 0 ; i < n ;i ++){

        int sum = 0 ;

        for(int j = m - 1 ; j >= 0 ; j --){
            if(arr[i][j] == 'O')sum ++ ;
            cumo[i][j] = sum ;
        }

    }
    for(int i = 0 ;i < n ; i ++){
        for(int j = 0 ;j < m ; j ++){
            if(arr[i][j] == 'J'){
                ans += 1ll * cumi[i][j] * cumo[i][j];

            }
        }
    }
    cout << ans ;


}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 312 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 444 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 448 KB Output is correct
9 Correct 1 ms 460 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 460 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 312 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 444 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 448 KB Output is correct
9 Correct 1 ms 460 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 460 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 7 ms 3824 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 4 ms 2636 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 8 ms 4812 KB Output is correct
19 Correct 7 ms 4684 KB Output is correct
20 Correct 7 ms 4676 KB Output is correct
21 Correct 8 ms 4872 KB Output is correct
22 Correct 7 ms 4620 KB Output is correct
23 Correct 7 ms 4684 KB Output is correct
24 Correct 9 ms 4812 KB Output is correct
25 Correct 7 ms 4684 KB Output is correct
26 Correct 7 ms 4780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 312 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 444 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 448 KB Output is correct
9 Correct 1 ms 460 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 460 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 7 ms 3824 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 4 ms 2636 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 8 ms 4812 KB Output is correct
19 Correct 7 ms 4684 KB Output is correct
20 Correct 7 ms 4676 KB Output is correct
21 Correct 8 ms 4872 KB Output is correct
22 Correct 7 ms 4620 KB Output is correct
23 Correct 7 ms 4684 KB Output is correct
24 Correct 9 ms 4812 KB Output is correct
25 Correct 7 ms 4684 KB Output is correct
26 Correct 7 ms 4780 KB Output is correct
27 Correct 376 ms 150904 KB Output is correct
28 Correct 2 ms 1100 KB Output is correct
29 Correct 21 ms 12108 KB Output is correct
30 Correct 1 ms 972 KB Output is correct
31 Correct 278 ms 111160 KB Output is correct
32 Correct 372 ms 158692 KB Output is correct
33 Correct 376 ms 159208 KB Output is correct
34 Correct 323 ms 128964 KB Output is correct
35 Correct 376 ms 158652 KB Output is correct
36 Correct 374 ms 159216 KB Output is correct
37 Correct 412 ms 159748 KB Output is correct
38 Correct 298 ms 110404 KB Output is correct
39 Correct 286 ms 110620 KB Output is correct