Submission #247682

# Submission time Handle Problem Language Result Execution time Memory
247682 2020-07-11T23:13:38 Z WhaleVomit Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
176 ms 159356 KB
#include <bits/stdc++.h>
using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for(int i=a; i<b; i++)
#define M00(i, a) for(int i=0; i<a; i++)
#define MOOd(i,a,b) for(int i = (b)-1; i >= a; i--)
#define M00d(i,a) for(int i = (a)-1; i>=0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _ << " _ " <<

template<class T> bool ckmin(T& a, const T& b) {return b < a ? a = b, 1 : 0;}
template<class T> bool ckmax(T& a, const T& b) {return a < b ? a = b, 1 : 0;}

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ld,ld> pd;
typedef complex<ld> cd;

const int MAX_N = 3010;
int n, m;
char arr[MAX_N][MAX_N];
ll icnt[MAX_N][MAX_N];
ll ocnt[MAX_N][MAX_N];

int main() { FAST
    cin >> n >> m;
    M00(i, n) {
        string s; cin >> s;
        M00(j, m) arr[i][j] = s[j];
    }
    M00d(i, n) {
        M00(j, m) {
            if(i == n-1) icnt[i][j] = 0;
            else icnt[i][j] = ((arr[i+1][j] == 'I') + icnt[i+1][j]);
        }
    }
    M00(i, n) {
        M00d(j, m) {
            if(j == m-1) ocnt[i][j] = 0;
            else ocnt[i][j] = ((arr[i][j+1] == 'O') + ocnt[i][j+1]);
        }
    }
    ll res = 0;
    M00(i, n) M00(j, m) {
        if(arr[i][j] == 'J') {
            res += ocnt[i][j] * icnt[i][j];
        }
    }
    finish(res);
}

# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 6 ms 512 KB Output is correct
5 Correct 6 ms 1664 KB Output is correct
6 Correct 5 ms 1664 KB Output is correct
7 Correct 5 ms 1536 KB Output is correct
8 Correct 5 ms 1664 KB Output is correct
9 Correct 5 ms 1536 KB Output is correct
10 Correct 6 ms 1536 KB Output is correct
11 Correct 5 ms 1664 KB Output is correct
12 Correct 6 ms 1552 KB Output is correct
13 Correct 5 ms 1536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 6 ms 512 KB Output is correct
5 Correct 6 ms 1664 KB Output is correct
6 Correct 5 ms 1664 KB Output is correct
7 Correct 5 ms 1536 KB Output is correct
8 Correct 5 ms 1664 KB Output is correct
9 Correct 5 ms 1536 KB Output is correct
10 Correct 6 ms 1536 KB Output is correct
11 Correct 5 ms 1664 KB Output is correct
12 Correct 6 ms 1552 KB Output is correct
13 Correct 5 ms 1536 KB Output is correct
14 Correct 10 ms 9088 KB Output is correct
15 Correct 7 ms 5120 KB Output is correct
16 Correct 7 ms 5376 KB Output is correct
17 Correct 5 ms 512 KB Output is correct
18 Correct 11 ms 9984 KB Output is correct
19 Correct 11 ms 9856 KB Output is correct
20 Correct 10 ms 9856 KB Output is correct
21 Correct 11 ms 9984 KB Output is correct
22 Correct 10 ms 9728 KB Output is correct
23 Correct 10 ms 9856 KB Output is correct
24 Correct 12 ms 9984 KB Output is correct
25 Correct 10 ms 9856 KB Output is correct
26 Correct 10 ms 9856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 6 ms 512 KB Output is correct
5 Correct 6 ms 1664 KB Output is correct
6 Correct 5 ms 1664 KB Output is correct
7 Correct 5 ms 1536 KB Output is correct
8 Correct 5 ms 1664 KB Output is correct
9 Correct 5 ms 1536 KB Output is correct
10 Correct 6 ms 1536 KB Output is correct
11 Correct 5 ms 1664 KB Output is correct
12 Correct 6 ms 1552 KB Output is correct
13 Correct 5 ms 1536 KB Output is correct
14 Correct 10 ms 9088 KB Output is correct
15 Correct 7 ms 5120 KB Output is correct
16 Correct 7 ms 5376 KB Output is correct
17 Correct 5 ms 512 KB Output is correct
18 Correct 11 ms 9984 KB Output is correct
19 Correct 11 ms 9856 KB Output is correct
20 Correct 10 ms 9856 KB Output is correct
21 Correct 11 ms 9984 KB Output is correct
22 Correct 10 ms 9728 KB Output is correct
23 Correct 10 ms 9856 KB Output is correct
24 Correct 12 ms 9984 KB Output is correct
25 Correct 10 ms 9856 KB Output is correct
26 Correct 10 ms 9856 KB Output is correct
27 Correct 161 ms 158840 KB Output is correct
28 Correct 16 ms 26368 KB Output is correct
29 Correct 14 ms 13952 KB Output is correct
30 Correct 5 ms 896 KB Output is correct
31 Correct 125 ms 131576 KB Output is correct
32 Correct 137 ms 159224 KB Output is correct
33 Correct 139 ms 158840 KB Output is correct
34 Correct 152 ms 152752 KB Output is correct
35 Correct 141 ms 159224 KB Output is correct
36 Correct 129 ms 158844 KB Output is correct
37 Correct 176 ms 159356 KB Output is correct
38 Correct 112 ms 130808 KB Output is correct
39 Correct 106 ms 131064 KB Output is correct