Submission #208064

# Submission time Handle Problem Language Result Execution time Memory
208064 2020-03-10T00:32:45 Z ToMmyDong Bitaro the Brave (JOI19_ho_t1) C++11
100 / 100
413 ms 88568 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define REP(i,n) for(int i=0;i<n;++i)
#define REP1(i,n) for(int i=1;i<=n;++i)
#define SZ(i) int(i.size())
#define eb emplace_back
#define ALL(i) i.begin(),i.end()
#define X first
#define Y second
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"#%d: %s = ",__LINE__,#__VA_ARGS__),_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
template<typename It> ostream& _printRng(ostream &os,It bg,It ed)
{
    os<<"{";
    for(It it=bg;it!=ed;it++) {
        os<<(it==bg?"":",")<<*it;
    }
    os<<"}";
    return os;
}
template<typename T> ostream &operator << (ostream &os,vector<T> &v){return _printRng(os,v.begin(), v.end());}
template<typename T> void pary(T bg, T ed){_printRng(cerr,bg,ed);cerr<<endl;}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#define pary(...)
#endif

const int MAXN = 3003;
const ll MOD = 1000000007;

int n, m;
char c[MAXN][MAXN];
int O[MAXN][MAXN], I[MAXN][MAXN];
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> n >> m;
    REP (i, n) {
        REP (j, m) {
            cin >> c[i][j];
        }
    }

    for (int i=0; i<n; i++) {
        int sum = 0;
        for (int j=m-1; j>=0; j--) {
            sum += c[i][j] == 'O';
            O[i][j] = sum;
        }
    }

    for (int j=0; j<m; j++) {
        int sum = 0;
        for (int i=n-1; i>=0; i--) {
            sum += c[i][j] == 'I';
            I[i][j] = sum;
        }
    }

    ll ans = 0;
    for (int i=0; i<n; i++) {
        for (int j=0; j<m; j++) {
            if (c[i][j] == 'J') {
                ans += O[i][j] * I[i][j];
            }
        }
    }

    cout << ans << endl;


}

/*
3 4
JOIJ
JIOO
IIII
*/
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 372 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 1528 KB Output is correct
6 Correct 5 ms 1528 KB Output is correct
7 Correct 5 ms 1272 KB Output is correct
8 Correct 6 ms 1528 KB Output is correct
9 Correct 5 ms 1528 KB Output is correct
10 Correct 5 ms 1400 KB Output is correct
11 Correct 5 ms 1528 KB Output is correct
12 Correct 5 ms 1528 KB Output is correct
13 Correct 5 ms 1400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 372 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 1528 KB Output is correct
6 Correct 5 ms 1528 KB Output is correct
7 Correct 5 ms 1272 KB Output is correct
8 Correct 6 ms 1528 KB Output is correct
9 Correct 5 ms 1528 KB Output is correct
10 Correct 5 ms 1400 KB Output is correct
11 Correct 5 ms 1528 KB Output is correct
12 Correct 5 ms 1528 KB Output is correct
13 Correct 5 ms 1400 KB Output is correct
14 Correct 12 ms 7544 KB Output is correct
15 Correct 7 ms 4984 KB Output is correct
16 Correct 9 ms 4344 KB Output is correct
17 Correct 5 ms 504 KB Output is correct
18 Correct 16 ms 8056 KB Output is correct
19 Correct 13 ms 7960 KB Output is correct
20 Correct 12 ms 7800 KB Output is correct
21 Correct 13 ms 8056 KB Output is correct
22 Correct 13 ms 7928 KB Output is correct
23 Correct 16 ms 7928 KB Output is correct
24 Correct 15 ms 8056 KB Output is correct
25 Correct 12 ms 7928 KB Output is correct
26 Correct 13 ms 7800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 372 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 1528 KB Output is correct
6 Correct 5 ms 1528 KB Output is correct
7 Correct 5 ms 1272 KB Output is correct
8 Correct 6 ms 1528 KB Output is correct
9 Correct 5 ms 1528 KB Output is correct
10 Correct 5 ms 1400 KB Output is correct
11 Correct 5 ms 1528 KB Output is correct
12 Correct 5 ms 1528 KB Output is correct
13 Correct 5 ms 1400 KB Output is correct
14 Correct 12 ms 7544 KB Output is correct
15 Correct 7 ms 4984 KB Output is correct
16 Correct 9 ms 4344 KB Output is correct
17 Correct 5 ms 504 KB Output is correct
18 Correct 16 ms 8056 KB Output is correct
19 Correct 13 ms 7960 KB Output is correct
20 Correct 12 ms 7800 KB Output is correct
21 Correct 13 ms 8056 KB Output is correct
22 Correct 13 ms 7928 KB Output is correct
23 Correct 16 ms 7928 KB Output is correct
24 Correct 15 ms 8056 KB Output is correct
25 Correct 12 ms 7928 KB Output is correct
26 Correct 13 ms 7800 KB Output is correct
27 Correct 385 ms 88036 KB Output is correct
28 Correct 21 ms 26104 KB Output is correct
29 Correct 19 ms 7800 KB Output is correct
30 Correct 5 ms 632 KB Output is correct
31 Correct 287 ms 72568 KB Output is correct
32 Correct 375 ms 88440 KB Output is correct
33 Correct 367 ms 88184 KB Output is correct
34 Correct 333 ms 84088 KB Output is correct
35 Correct 375 ms 88568 KB Output is correct
36 Correct 362 ms 88136 KB Output is correct
37 Correct 413 ms 88568 KB Output is correct
38 Correct 257 ms 72568 KB Output is correct
39 Correct 255 ms 72440 KB Output is correct