답안 #623203

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
623203 2022-08-05T10:22:16 Z Abrar_Al_Samit Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
364 ms 159012 KB
#include<bits/stdc++.h>
using namespace std;

void PlayGround() {
  int n, m;
  cin>>n>>m;
  char c[n+2][m+2];
  for(int i=1; i<=n; ++i) {
    for(int j=1; j<=m; ++j) {
      cin>>c[i][j];
    }
  }  

  long long O[n+2][m+2];
  long long I[n+2][m+2];

  memset(O, 0, sizeof O);
  memset(I, 0, sizeof I);

  for(int i=1; i<=n; ++i) {
    for(int j=1; j<=m; ++j) {
      if(c[i][j]=='O') O[i][j] = 1;
      else if(c[i][j]=='I') I[i][j] = 1;
    }
  }

  for(int i=1; i<=n; ++i) {
    for(int j=m; j>0; --j) {
      O[i][j] += O[i][j+1];
    }
  }

  for(int j=1; j<=m; ++j) {
    for(int i=n; i>0; --i) {
      I[i][j] += I[i+1][j];
    }
  }

  long long ans = 0;
  for(int i=1; i<=n; ++i) {
    for(int j=1; j<=m; ++j) if(c[i][j]=='J') {
      ans += O[i][j+1] * I[i+1][j];
    }
  }
  cout<<ans<<'\n';

}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  PlayGround();
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 244 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 316 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 464 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 460 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 244 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 316 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 464 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 460 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 7 ms 3692 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 4 ms 2516 KB Output is correct
17 Correct 0 ms 320 KB Output is correct
18 Correct 9 ms 4640 KB Output is correct
19 Correct 7 ms 4628 KB Output is correct
20 Correct 7 ms 4564 KB Output is correct
21 Correct 9 ms 4760 KB Output is correct
22 Correct 6 ms 4564 KB Output is correct
23 Correct 6 ms 4564 KB Output is correct
24 Correct 10 ms 4760 KB Output is correct
25 Correct 8 ms 4560 KB Output is correct
26 Correct 7 ms 4564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 244 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 316 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 464 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 460 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 7 ms 3692 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 4 ms 2516 KB Output is correct
17 Correct 0 ms 320 KB Output is correct
18 Correct 9 ms 4640 KB Output is correct
19 Correct 7 ms 4628 KB Output is correct
20 Correct 7 ms 4564 KB Output is correct
21 Correct 9 ms 4760 KB Output is correct
22 Correct 6 ms 4564 KB Output is correct
23 Correct 6 ms 4564 KB Output is correct
24 Correct 10 ms 4760 KB Output is correct
25 Correct 8 ms 4560 KB Output is correct
26 Correct 7 ms 4564 KB Output is correct
27 Correct 348 ms 150188 KB Output is correct
28 Correct 1 ms 852 KB Output is correct
29 Correct 21 ms 11732 KB Output is correct
30 Correct 2 ms 756 KB Output is correct
31 Correct 270 ms 110476 KB Output is correct
32 Correct 319 ms 158032 KB Output is correct
33 Correct 304 ms 158456 KB Output is correct
34 Correct 295 ms 128268 KB Output is correct
35 Correct 306 ms 158048 KB Output is correct
36 Correct 299 ms 158412 KB Output is correct
37 Correct 364 ms 159012 KB Output is correct
38 Correct 210 ms 109668 KB Output is correct
39 Correct 202 ms 110108 KB Output is correct