답안 #163042

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
163042 2019-11-11T06:56:31 Z fluffypotato Bitaro the Brave (JOI19_ho_t1) Java 11
100 / 100
839 ms 147972 KB
import java.util.*;
import java.io.*;

 class joi2019_ho_t1 {
    public static void main(String[] args) throws IOException{
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new PrintStream(System.out));
        StringTokenizer st=new StringTokenizer(f.readLine());
        int n=Integer.parseInt(st.nextToken());
        int m=Integer.parseInt(st.nextToken());
        char[][]arr=new char[n][m];
        int[][]arrI=new int[n][m];
        int[][]arrO=new int[n][m];
        for(int i=0;i<n;i++){
            String a=f.readLine();
            for(int j=0;j<m;j++){
                arr[i][j]=a.charAt(j);
                arrO[i][j]=j==0?0:arrO[i][j-1];
                arrI[i][j]=i==0?0:arrI[i-1][j];
                if(arr[i][j]=='O'){
                    arrO[i][j]++;
                }
                else if(arr[i][j]=='I'){
                    arrI[i][j]++;
                }
            }
        }
        long ans=0;
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                if(arr[i][j]!='J')continue;
                int x=i==0?arrI[n-1][j]:arrI[n-1][j]-arrI[i-1][j];
                int y=j==0?arrO[i][m-1]:arrO[i][m-1]-arrO[i][j-1];
                ans+=x*y;
            }
        }
        System.out.print(ans);
        f.close();
        out.close();
    }
}
class pair implements Comparable <pair>{
    int num;
    int idx;

    public int compareTo(pair other){
        return num- other.num;
    }


    pair(int a, int b)
    {
        num=a;
        idx=b;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 90 ms 9720 KB Output is correct
2 Correct 92 ms 9752 KB Output is correct
3 Correct 87 ms 9768 KB Output is correct
4 Correct 89 ms 9832 KB Output is correct
5 Correct 97 ms 10100 KB Output is correct
6 Correct 94 ms 10052 KB Output is correct
7 Correct 93 ms 9820 KB Output is correct
8 Correct 100 ms 9808 KB Output is correct
9 Correct 98 ms 9980 KB Output is correct
10 Correct 98 ms 10068 KB Output is correct
11 Correct 98 ms 9740 KB Output is correct
12 Correct 96 ms 9904 KB Output is correct
13 Correct 112 ms 9992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 90 ms 9720 KB Output is correct
2 Correct 92 ms 9752 KB Output is correct
3 Correct 87 ms 9768 KB Output is correct
4 Correct 89 ms 9832 KB Output is correct
5 Correct 97 ms 10100 KB Output is correct
6 Correct 94 ms 10052 KB Output is correct
7 Correct 93 ms 9820 KB Output is correct
8 Correct 100 ms 9808 KB Output is correct
9 Correct 98 ms 9980 KB Output is correct
10 Correct 98 ms 10068 KB Output is correct
11 Correct 98 ms 9740 KB Output is correct
12 Correct 96 ms 9904 KB Output is correct
13 Correct 112 ms 9992 KB Output is correct
14 Correct 176 ms 15364 KB Output is correct
15 Correct 109 ms 10132 KB Output is correct
16 Correct 148 ms 14348 KB Output is correct
17 Correct 93 ms 9864 KB Output is correct
18 Correct 168 ms 16284 KB Output is correct
19 Correct 155 ms 15740 KB Output is correct
20 Correct 187 ms 15844 KB Output is correct
21 Correct 166 ms 15944 KB Output is correct
22 Correct 195 ms 16184 KB Output is correct
23 Correct 158 ms 16000 KB Output is correct
24 Correct 189 ms 16588 KB Output is correct
25 Correct 175 ms 15996 KB Output is correct
26 Correct 202 ms 16360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 90 ms 9720 KB Output is correct
2 Correct 92 ms 9752 KB Output is correct
3 Correct 87 ms 9768 KB Output is correct
4 Correct 89 ms 9832 KB Output is correct
5 Correct 97 ms 10100 KB Output is correct
6 Correct 94 ms 10052 KB Output is correct
7 Correct 93 ms 9820 KB Output is correct
8 Correct 100 ms 9808 KB Output is correct
9 Correct 98 ms 9980 KB Output is correct
10 Correct 98 ms 10068 KB Output is correct
11 Correct 98 ms 9740 KB Output is correct
12 Correct 96 ms 9904 KB Output is correct
13 Correct 112 ms 9992 KB Output is correct
14 Correct 176 ms 15364 KB Output is correct
15 Correct 109 ms 10132 KB Output is correct
16 Correct 148 ms 14348 KB Output is correct
17 Correct 93 ms 9864 KB Output is correct
18 Correct 168 ms 16284 KB Output is correct
19 Correct 155 ms 15740 KB Output is correct
20 Correct 187 ms 15844 KB Output is correct
21 Correct 166 ms 15944 KB Output is correct
22 Correct 195 ms 16184 KB Output is correct
23 Correct 158 ms 16000 KB Output is correct
24 Correct 189 ms 16588 KB Output is correct
25 Correct 175 ms 15996 KB Output is correct
26 Correct 202 ms 16360 KB Output is correct
27 Correct 762 ms 132088 KB Output is correct
28 Correct 105 ms 10848 KB Output is correct
29 Correct 239 ms 21536 KB Output is correct
30 Correct 95 ms 10000 KB Output is correct
31 Correct 652 ms 114028 KB Output is correct
32 Correct 708 ms 138212 KB Output is correct
33 Correct 797 ms 147092 KB Output is correct
34 Correct 765 ms 132108 KB Output is correct
35 Correct 666 ms 147240 KB Output is correct
36 Correct 720 ms 147256 KB Output is correct
37 Correct 839 ms 147972 KB Output is correct
38 Correct 540 ms 118872 KB Output is correct
39 Correct 605 ms 119148 KB Output is correct