답안 #851251

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
851251 2023-09-19T06:41:44 Z askow Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
384 ms 159112 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    char a[n+1][m+1];
    for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)cin>>a[i][j];
    int ans=0;
    int suf[n+1][m+2];
    for(int i=0;i<=n;i++)for(int j=0;j<=m+1;j++)suf[i][j]=0;
    for(int i=1;i<=n;i++){
        for(int j=m;j>=1;j--){
            suf[i][j]=suf[i][j+1];
            if(a[i][j]=='O')suf[i][j]++;
        }
    }
    int dp[n+2][m+2];
    for(int i=0;i<=n+1;i++)for(int j=0;j<=m+1;j++)dp[i][j]=0;
    for(int i=1;i<=m;i++){
        for(int j=n;j>=1;j--){
            dp[j][i]=dp[j+1][i];
            if(a[j][i]=='I')dp[j][i]++;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(a[i][j]=='J'){
                int Z=dp[i+1][j];
                int R=suf[i][j+1];/*
                for(int k=i+1;k<=n;k++){
                    if(a[k][j]=='I')Z++;
                }*/
                /*
                for(int k=j+1;k<=m;k++){
                    if(a[i][k]=='O')R++;
                }*/
                ans+=Z*R;
            }
        }
    }
    cout<<ans;
}
// bitset fora?
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 360 KB Output is correct
3 Correct 0 ms 360 KB Output is correct
4 Correct 0 ms 360 KB Output is correct
5 Correct 1 ms 616 KB Output is correct
6 Correct 1 ms 360 KB Output is correct
7 Correct 1 ms 612 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 360 KB Output is correct
3 Correct 0 ms 360 KB Output is correct
4 Correct 0 ms 360 KB Output is correct
5 Correct 1 ms 616 KB Output is correct
6 Correct 1 ms 360 KB Output is correct
7 Correct 1 ms 612 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 6 ms 3420 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 2392 KB Output is correct
17 Correct 0 ms 356 KB Output is correct
18 Correct 9 ms 4456 KB Output is correct
19 Correct 6 ms 4284 KB Output is correct
20 Correct 7 ms 4456 KB Output is correct
21 Correct 7 ms 4456 KB Output is correct
22 Correct 6 ms 4456 KB Output is correct
23 Correct 6 ms 4456 KB Output is correct
24 Correct 7 ms 4456 KB Output is correct
25 Correct 6 ms 4456 KB Output is correct
26 Correct 6 ms 4548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 360 KB Output is correct
3 Correct 0 ms 360 KB Output is correct
4 Correct 0 ms 360 KB Output is correct
5 Correct 1 ms 616 KB Output is correct
6 Correct 1 ms 360 KB Output is correct
7 Correct 1 ms 612 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 6 ms 3420 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 3 ms 2392 KB Output is correct
17 Correct 0 ms 356 KB Output is correct
18 Correct 9 ms 4456 KB Output is correct
19 Correct 6 ms 4284 KB Output is correct
20 Correct 7 ms 4456 KB Output is correct
21 Correct 7 ms 4456 KB Output is correct
22 Correct 6 ms 4456 KB Output is correct
23 Correct 6 ms 4456 KB Output is correct
24 Correct 7 ms 4456 KB Output is correct
25 Correct 6 ms 4456 KB Output is correct
26 Correct 6 ms 4548 KB Output is correct
27 Correct 350 ms 141980 KB Output is correct
28 Correct 1 ms 872 KB Output is correct
29 Correct 17 ms 11936 KB Output is correct
30 Correct 1 ms 872 KB Output is correct
31 Correct 254 ms 110480 KB Output is correct
32 Correct 352 ms 158052 KB Output is correct
33 Correct 343 ms 158568 KB Output is correct
34 Correct 290 ms 128260 KB Output is correct
35 Correct 338 ms 158040 KB Output is correct
36 Correct 332 ms 158820 KB Output is correct
37 Correct 384 ms 159112 KB Output is correct
38 Correct 219 ms 109756 KB Output is correct
39 Correct 221 ms 110448 KB Output is correct