Submission #863951

# Submission time Handle Problem Language Result Execution time Memory
863951 2023-10-21T14:29:13 Z Arthas Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
130 ms 54352 KB
/// I'm only brave when I have to be
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define fast_io ios::sync_with_stdio(false);cin.tie(NULL);
#define file_io freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define FOR(i,k,n) for(int i = k; i < n; ++ i)
#define debf cout<<"(0-0)\n";
#define all(x) x.begin(), x.end()
#define dec(x) cout << fixed << setprecision(x);
#define pf push_front
#define ppf pop_front
#define dash " ------- "
#define what(x) cerr << #x << " is " << x << endl;
#define eb emplace_back
//#define int short int
//#define int long long
#define sz(s) (int) (s.size())
#define fl cout.flush()

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <int, pii> pip;
typedef pair <pii, int> ppi;
typedef pair <ll, ll> pll;
typedef unsigned long long ull;
typedef long double ld;

template <class T> using max_heap = priority_queue <T, vector <T>, less <T> >;
template <class T> using min_heap = priority_queue <T, vector <T>, greater <T> >;

constexpr int MOD = 1e9 + 7, N = 3008, M = 1e5 + 8, SQ = 500, INF = 2e9 + 8, LGN = 11, mod = 998244353;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, m, cnt1[N][N];
ll ans;
string s[N];

int32_t main(){
  fast_io;
  cin >> n >> m;
  FOR (i, 0, n){
    cin >> s[i];
  }
  for (int i = 0; i < n; ++ i){
    for (int j = m - 1; j >= 0; -- j){
      cnt1[i][j] = cnt1[i][j+1] + (s[i][j] == 'O');
    }
  }
  int x = 0;
  for (int j = 0; j < m; ++ j){
    for (int i = n - 1; i >= 0; -- i){
      x += s[i][j] == 'I';
      if (s[i][j] == 'J'){
        ans += 1LL * cnt1[i][j] * x;
      }
    }
    x = 0;
  }
  cout << ans;
  return 0;
}

// Yesterday is history
// Tomorrow is a mystery
// but today is a gift
// That is why it is called the present
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 564 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 828 KB Output is correct
6 Correct 1 ms 860 KB Output is correct
7 Correct 1 ms 860 KB Output is correct
8 Correct 1 ms 1112 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
12 Correct 1 ms 860 KB Output is correct
13 Correct 1 ms 856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 564 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 828 KB Output is correct
6 Correct 1 ms 860 KB Output is correct
7 Correct 1 ms 860 KB Output is correct
8 Correct 1 ms 1112 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
12 Correct 1 ms 860 KB Output is correct
13 Correct 1 ms 856 KB Output is correct
14 Correct 3 ms 3676 KB Output is correct
15 Correct 1 ms 2140 KB Output is correct
16 Correct 2 ms 2140 KB Output is correct
17 Correct 0 ms 604 KB Output is correct
18 Correct 4 ms 4080 KB Output is correct
19 Correct 3 ms 3932 KB Output is correct
20 Correct 3 ms 3992 KB Output is correct
21 Correct 4 ms 3980 KB Output is correct
22 Correct 3 ms 4188 KB Output is correct
23 Correct 3 ms 3932 KB Output is correct
24 Correct 4 ms 3932 KB Output is correct
25 Correct 3 ms 3932 KB Output is correct
26 Correct 3 ms 3932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 564 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 828 KB Output is correct
6 Correct 1 ms 860 KB Output is correct
7 Correct 1 ms 860 KB Output is correct
8 Correct 1 ms 1112 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
12 Correct 1 ms 860 KB Output is correct
13 Correct 1 ms 856 KB Output is correct
14 Correct 3 ms 3676 KB Output is correct
15 Correct 1 ms 2140 KB Output is correct
16 Correct 2 ms 2140 KB Output is correct
17 Correct 0 ms 604 KB Output is correct
18 Correct 4 ms 4080 KB Output is correct
19 Correct 3 ms 3932 KB Output is correct
20 Correct 3 ms 3992 KB Output is correct
21 Correct 4 ms 3980 KB Output is correct
22 Correct 3 ms 4188 KB Output is correct
23 Correct 3 ms 3932 KB Output is correct
24 Correct 4 ms 3932 KB Output is correct
25 Correct 3 ms 3932 KB Output is correct
26 Correct 3 ms 3932 KB Output is correct
27 Correct 110 ms 53292 KB Output is correct
28 Correct 5 ms 10332 KB Output is correct
29 Correct 6 ms 4960 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Correct 83 ms 42684 KB Output is correct
32 Correct 86 ms 54100 KB Output is correct
33 Correct 100 ms 54132 KB Output is correct
34 Correct 108 ms 49364 KB Output is correct
35 Correct 110 ms 54192 KB Output is correct
36 Correct 108 ms 54352 KB Output is correct
37 Correct 130 ms 54292 KB Output is correct
38 Correct 57 ms 42640 KB Output is correct
39 Correct 60 ms 42324 KB Output is correct