Submission #127605

# Submission time Handle Problem Language Result Execution time Memory
127605 2019-07-09T16:15:39 Z IOrtroiii Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
332 ms 88904 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 3030;

char a[N][N];
int row[N][N];
int col[N][N];

int main() {
   int n, m;
   scanf("%d %d", &n, &m);
   for (int i = 1; i <= n; ++i) {
      scanf("%s", a[i] + 1);
   }
   for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= m; ++j) {
         if (a[i][j] == 'O') {
            ++row[i][j];
         } else if (a[i][j] == 'I') {
            ++col[i][j];
         }
      }
   }
   for (int i = 1; i <= n; ++i) {
      for (int j = m; j > 0; --j) {
         row[i][j] += row[i][j + 1];
      }
   }
   for (int j = 1; j <= m; ++j) {
      for (int i = n; i > 0; --i) {
         col[i][j] += col[i + 1][j];
      }
   }
   long long ans = 0;
   for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= m; ++j) {
         if (a[i][j] == 'J') {
            ans += row[i][j] * col[i][j];
         }
      }
   }
   printf("%lld\n", ans);
}

Compilation message

joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:13:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d %d", &n, &m);
    ~~~~~^~~~~~~~~~~~~~~~~
joi2019_ho_t1.cpp:15:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%s", a[i] + 1);
       ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 1528 KB Output is correct
6 Correct 3 ms 1528 KB Output is correct
7 Correct 3 ms 1400 KB Output is correct
8 Correct 3 ms 1532 KB Output is correct
9 Correct 3 ms 1528 KB Output is correct
10 Correct 3 ms 1400 KB Output is correct
11 Correct 4 ms 1528 KB Output is correct
12 Correct 3 ms 1528 KB Output is correct
13 Correct 4 ms 1400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 1528 KB Output is correct
6 Correct 3 ms 1528 KB Output is correct
7 Correct 3 ms 1400 KB Output is correct
8 Correct 3 ms 1532 KB Output is correct
9 Correct 3 ms 1528 KB Output is correct
10 Correct 3 ms 1400 KB Output is correct
11 Correct 4 ms 1528 KB Output is correct
12 Correct 3 ms 1528 KB Output is correct
13 Correct 4 ms 1400 KB Output is correct
14 Correct 12 ms 7544 KB Output is correct
15 Correct 6 ms 4984 KB Output is correct
16 Correct 6 ms 4220 KB Output is correct
17 Correct 3 ms 508 KB Output is correct
18 Correct 14 ms 8056 KB Output is correct
19 Correct 11 ms 7932 KB Output is correct
20 Correct 10 ms 7928 KB Output is correct
21 Correct 14 ms 8056 KB Output is correct
22 Correct 11 ms 7928 KB Output is correct
23 Correct 12 ms 7928 KB Output is correct
24 Correct 14 ms 8056 KB Output is correct
25 Correct 12 ms 7900 KB Output is correct
26 Correct 12 ms 7928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 1528 KB Output is correct
6 Correct 3 ms 1528 KB Output is correct
7 Correct 3 ms 1400 KB Output is correct
8 Correct 3 ms 1532 KB Output is correct
9 Correct 3 ms 1528 KB Output is correct
10 Correct 3 ms 1400 KB Output is correct
11 Correct 4 ms 1528 KB Output is correct
12 Correct 3 ms 1528 KB Output is correct
13 Correct 4 ms 1400 KB Output is correct
14 Correct 12 ms 7544 KB Output is correct
15 Correct 6 ms 4984 KB Output is correct
16 Correct 6 ms 4220 KB Output is correct
17 Correct 3 ms 508 KB Output is correct
18 Correct 14 ms 8056 KB Output is correct
19 Correct 11 ms 7932 KB Output is correct
20 Correct 10 ms 7928 KB Output is correct
21 Correct 14 ms 8056 KB Output is correct
22 Correct 11 ms 7928 KB Output is correct
23 Correct 12 ms 7928 KB Output is correct
24 Correct 14 ms 8056 KB Output is correct
25 Correct 12 ms 7900 KB Output is correct
26 Correct 12 ms 7928 KB Output is correct
27 Correct 318 ms 88824 KB Output is correct
28 Correct 23 ms 26104 KB Output is correct
29 Correct 14 ms 7800 KB Output is correct
30 Correct 3 ms 632 KB Output is correct
31 Correct 221 ms 73080 KB Output is correct
32 Correct 227 ms 88824 KB Output is correct
33 Correct 225 ms 88696 KB Output is correct
34 Correct 256 ms 84728 KB Output is correct
35 Correct 231 ms 88824 KB Output is correct
36 Correct 226 ms 88680 KB Output is correct
37 Correct 332 ms 88904 KB Output is correct
38 Correct 160 ms 73080 KB Output is correct
39 Correct 157 ms 72828 KB Output is correct