답안 #1092376

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1092376 2024-09-24T00:30:45 Z Flandre Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
462 ms 81280 KB
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
 
const int NMAX = 3069;
 
int vals[NMAX][NMAX];
int oscores[NMAX][NMAX];
bool iexist[NMAX];
bool jexist[NMAX];
 
int main() {
  int I, J;
  cin >> I >> J;
 
  for (int i = 1; i <= I; i++) {
    for (int j = 1; j <= J; j++) {
      char v;
      cin >> v;
      
      if (v == 'J') {
        vals[i][j] = 1;
        iexist[i] = true;
        jexist[j] = true;
      } else if (v == 'I') {
        vals[i][j] = 2;
      } else {
        vals[i][j] = 3;
      }
    }
  }
 
  for (int i = I - 1; i > 0; i--) {
    if (!iexist[i]) continue;
    ll oscore = 0;
    for (int j = J; j > 0; j--) {
      if (vals[i][j] == 3) {
        oscore++;
      }
      oscores[i][j] = oscore;
    } 
  }
 
 
  // for (int i = 1; i <= I; i++) {
  //   for (int j = 1; j <= J; j++) {
  //     cout << oscores[i][j];
  //   }
  //   cout << endl;
  // }
 
  ll possibilities = 0;
 
  for (int j = J - 1; j > 0; j--) {
    if (!jexist[j]) continue;
    ll iscore = 0;
    for (int i = I; i > 0; i--) {
      if (vals[i][j] == 2) {
        iscore++;
      }
      if (vals[i][j] == 1) {
        possibilities += iscore * oscores[i][j];
      }
    } 
  }
 
  cout << possibilities << endl;
 
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 444 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 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 1116 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 444 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 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 1116 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 13 ms 6128 KB Output is correct
15 Correct 2 ms 3676 KB Output is correct
16 Correct 5 ms 3420 KB Output is correct
17 Correct 0 ms 448 KB Output is correct
18 Correct 14 ms 6784 KB Output is correct
19 Correct 10 ms 6836 KB Output is correct
20 Correct 11 ms 6744 KB Output is correct
21 Correct 14 ms 7000 KB Output is correct
22 Correct 13 ms 6748 KB Output is correct
23 Correct 9 ms 6748 KB Output is correct
24 Correct 14 ms 6916 KB Output is correct
25 Correct 10 ms 6748 KB Output is correct
26 Correct 9 ms 6856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 444 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 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 1116 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 13 ms 6128 KB Output is correct
15 Correct 2 ms 3676 KB Output is correct
16 Correct 5 ms 3420 KB Output is correct
17 Correct 0 ms 448 KB Output is correct
18 Correct 14 ms 6784 KB Output is correct
19 Correct 10 ms 6836 KB Output is correct
20 Correct 11 ms 6744 KB Output is correct
21 Correct 14 ms 7000 KB Output is correct
22 Correct 13 ms 6748 KB Output is correct
23 Correct 9 ms 6748 KB Output is correct
24 Correct 14 ms 6916 KB Output is correct
25 Correct 10 ms 6748 KB Output is correct
26 Correct 9 ms 6856 KB Output is correct
27 Correct 451 ms 80736 KB Output is correct
28 Correct 7 ms 18524 KB Output is correct
29 Correct 21 ms 7068 KB Output is correct
30 Correct 2 ms 604 KB Output is correct
31 Correct 322 ms 66540 KB Output is correct
32 Correct 406 ms 80976 KB Output is correct
33 Correct 329 ms 81004 KB Output is correct
34 Correct 406 ms 77136 KB Output is correct
35 Correct 390 ms 80996 KB Output is correct
36 Correct 351 ms 81028 KB Output is correct
37 Correct 462 ms 81280 KB Output is correct
38 Correct 248 ms 66136 KB Output is correct
39 Correct 236 ms 66132 KB Output is correct