Submission #970854

# Submission time Handle Problem Language Result Execution time Memory
970854 2024-04-27T11:36:14 Z MercubytheFirst Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
263 ms 160084 KB
#include <bits/stdc++.h>
using ll = long long;
#define pb push_back



// overflow check strat : a * b / b == a
using std::cin;
using std::cout;

template <typename T> 
std::ostream& operator<<( std::ostream& os, const std::vector<T>& v );
using namespace std;
const ll inf = 1e9 + 37;


void solve(){
  ll n, m;
  cin >> n >> m;
  vector<string> g(n);
  for(auto& s : g)
    cin >> s;
  vector<vector<ll> > osuf(n + 1, vector<ll>(m + 1)), isuf(n + 1, vector<ll>(m + 1));
  for(ll row = 0; row < n; ++row) {
    for(ll col = m - 1; col >= 0; --col) {
      osuf[row][col] = osuf[row][col + 1] + (g[row][col] == 'O');
    }
  }
  for(ll col = 0; col < m; ++col) {
    for(ll row = n - 1; row >= 0; --row) {
      isuf[row][col] = isuf[row + 1][col] + (g[row][col] == 'I');
    }
  }
  ll ans = 0;
  for(ll i = 0; i < n; ++i) {
    for(ll j = 0; j < m; ++j) {
      if(g[i][j] != 'J')
        continue;
      ans += osuf[i][j] * isuf[i][j];
    }
  }
  cout << ans << endl;
}   

signed main() {
  #ifdef LOCAL
  freopen("test.in", "r", stdin);
  freopen("test.out", "w", stdout);
  #endif
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  // signed t = 0; cin >> t; while(t--)
    solve();
}

template <typename T> 
std::ostream& operator<<( std::ostream& os, const std::vector<T>& v ) {
  os << "[";
  for (auto x : v)
    os << x << ", ";
  os << "]\n";
  return os;
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 456 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 0 ms 604 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 0 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 456 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 0 ms 604 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 0 ms 604 KB Output is correct
14 Correct 4 ms 3676 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 2 ms 2652 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 4 ms 4700 KB Output is correct
19 Correct 4 ms 4700 KB Output is correct
20 Correct 4 ms 4700 KB Output is correct
21 Correct 4 ms 4700 KB Output is correct
22 Correct 4 ms 4700 KB Output is correct
23 Correct 4 ms 4700 KB Output is correct
24 Correct 5 ms 4696 KB Output is correct
25 Correct 4 ms 4700 KB Output is correct
26 Correct 4 ms 4700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 456 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 0 ms 604 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 0 ms 604 KB Output is correct
14 Correct 4 ms 3676 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 2 ms 2652 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 4 ms 4700 KB Output is correct
19 Correct 4 ms 4700 KB Output is correct
20 Correct 4 ms 4700 KB Output is correct
21 Correct 4 ms 4700 KB Output is correct
22 Correct 4 ms 4700 KB Output is correct
23 Correct 4 ms 4700 KB Output is correct
24 Correct 5 ms 4696 KB Output is correct
25 Correct 4 ms 4700 KB Output is correct
26 Correct 4 ms 4700 KB Output is correct
27 Correct 251 ms 151372 KB Output is correct
28 Correct 1 ms 1116 KB Output is correct
29 Correct 9 ms 11996 KB Output is correct
30 Correct 1 ms 860 KB Output is correct
31 Correct 170 ms 111176 KB Output is correct
32 Correct 244 ms 158996 KB Output is correct
33 Correct 242 ms 159536 KB Output is correct
34 Correct 195 ms 129104 KB Output is correct
35 Correct 241 ms 159172 KB Output is correct
36 Correct 230 ms 160084 KB Output is correct
37 Correct 263 ms 160080 KB Output is correct
38 Correct 146 ms 110512 KB Output is correct
39 Correct 157 ms 110940 KB Output is correct