Submission #1023635

# Submission time Handle Problem Language Result Execution time Memory
1023635 2024-07-15T03:57:10 Z vjudge1 Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
171 ms 88560 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int N = 3005;

int n, m;
char a[N][N];
ll c[N][N];

void sol() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      cin >> a[i][j];
  ll ans = 0;
  for (int i = 1; i <= n; ++i) {
    ll cntO = 0;
    for (int j = m; j >= 1; --j) {
      if (a[i][j] == 'O') cntO++, c[i][j] = c[i-1][j];
      else if (a[i][j] == 'J') c[i][j] = c[i-1][j] + cntO;
      else ans += c[i-1][j], c[i][j] = c[i-1][j];
    }
  }
  cout << ans;
}

signed main() {
  cin.tie(0) -> sync_with_stdio(0);
  if (fopen("A.inp", "r")) freopen("A.inp", "r", stdin);
  int tc = 1; // cin >> tc;
  for (int test = 1; test <= tc; ++test) sol();
}

Compilation message

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:30:35: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |   if (fopen("A.inp", "r")) freopen("A.inp", "r", stdin);
      |                            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 0 ms 1116 KB Output is correct
7 Correct 1 ms 992 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1368 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 0 ms 1116 KB Output is correct
7 Correct 1 ms 992 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1368 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 5 ms 5468 KB Output is correct
15 Correct 1 ms 3420 KB Output is correct
16 Correct 2 ms 3248 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 7 ms 5980 KB Output is correct
19 Correct 4 ms 5980 KB Output is correct
20 Correct 4 ms 5944 KB Output is correct
21 Correct 5 ms 5980 KB Output is correct
22 Correct 4 ms 5892 KB Output is correct
23 Correct 4 ms 5980 KB Output is correct
24 Correct 5 ms 5984 KB Output is correct
25 Correct 4 ms 5980 KB Output is correct
26 Correct 4 ms 5804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 0 ms 1116 KB Output is correct
7 Correct 1 ms 992 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1368 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 1 ms 1116 KB Output is correct
14 Correct 5 ms 5468 KB Output is correct
15 Correct 1 ms 3420 KB Output is correct
16 Correct 2 ms 3248 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 7 ms 5980 KB Output is correct
19 Correct 4 ms 5980 KB Output is correct
20 Correct 4 ms 5944 KB Output is correct
21 Correct 5 ms 5980 KB Output is correct
22 Correct 4 ms 5892 KB Output is correct
23 Correct 4 ms 5980 KB Output is correct
24 Correct 5 ms 5984 KB Output is correct
25 Correct 4 ms 5980 KB Output is correct
26 Correct 4 ms 5804 KB Output is correct
27 Correct 139 ms 87892 KB Output is correct
28 Correct 6 ms 16732 KB Output is correct
29 Correct 9 ms 7900 KB Output is correct
30 Correct 1 ms 716 KB Output is correct
31 Correct 105 ms 72536 KB Output is correct
32 Correct 98 ms 88396 KB Output is correct
33 Correct 96 ms 88292 KB Output is correct
34 Correct 113 ms 84100 KB Output is correct
35 Correct 99 ms 88560 KB Output is correct
36 Correct 107 ms 88292 KB Output is correct
37 Correct 171 ms 88400 KB Output is correct
38 Correct 73 ms 72272 KB Output is correct
39 Correct 74 ms 72276 KB Output is correct