Submission #1083793

# Submission time Handle Problem Language Result Execution time Memory
1083793 2024-09-04T07:22:18 Z bvd Bitaro the Brave (JOI19_ho_t1) Java 11
100 / 100
272 ms 33448 KB
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class joi2019_ho_t1 {
	private static class Kattio extends PrintWriter {
		public Kattio(InputStream i) {
			super(new BufferedOutputStream(System.out));
			r = new BufferedReader(new InputStreamReader(i));
		}

		public Kattio(InputStream i, OutputStream o) {
			super(new BufferedOutputStream(o));
			r = new BufferedReader(new InputStreamReader(i));
		}

		public boolean hasMoreTokens() {
			return peekToken() != null;
		}

		public int getInt() {
			return Integer.parseInt(nextToken());
		}

		public double getDouble() {
			return Double.parseDouble(nextToken());
		}

		public long getLong() {
			return Long.parseLong(nextToken());
		}

		public String getWord() {
			return nextToken();
		}

		private BufferedReader r;
		private String line;
		private StringTokenizer st;
		private String token;

		private String peekToken() {
			if (token == null)
				try {
					while (st == null || !st.hasMoreTokens()) {
						line = r.readLine();
						if (line == null)
							return null;
						st = new StringTokenizer(line);
					}
					token = st.nextToken();
				} catch (IOException e) {
				}
			return token;
		}

		private String nextToken() {
			String ans = peekToken();
			token = null;
			return ans;
		}
	}
	
	public static void main(String[] args) {
		try (Kattio io = new Kattio(System.in, System.out)) {
			int n = io.getInt();
			int m = io.getInt();
			String[] table = new String[n];
			for (int i=0; i<n; ++i) {
				table[i] = io.getWord();
			}
			
			long[] cntRow = new long[m];
			int[] cntCol = new int[n];
			long result = 0;
			for (int i=n-1; i>=0; --i) {
				for (int j=m-1; j>=0; --j) {
					switch (table[i].charAt(j)) {
						case 'O': cntCol[i]++; break;
						case 'I': cntRow[j]++; break;
						default: result += cntRow[j] * cntCol[i];
					}
				}
			}
			
			io.println(result);
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 48 ms 8928 KB Output is correct
2 Correct 47 ms 8920 KB Output is correct
3 Correct 43 ms 9232 KB Output is correct
4 Correct 47 ms 8964 KB Output is correct
5 Correct 73 ms 10196 KB Output is correct
6 Correct 53 ms 8792 KB Output is correct
7 Correct 51 ms 9152 KB Output is correct
8 Correct 66 ms 10288 KB Output is correct
9 Correct 54 ms 8496 KB Output is correct
10 Correct 53 ms 8688 KB Output is correct
11 Correct 67 ms 10340 KB Output is correct
12 Correct 51 ms 9292 KB Output is correct
13 Correct 55 ms 8632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 8928 KB Output is correct
2 Correct 47 ms 8920 KB Output is correct
3 Correct 43 ms 9232 KB Output is correct
4 Correct 47 ms 8964 KB Output is correct
5 Correct 73 ms 10196 KB Output is correct
6 Correct 53 ms 8792 KB Output is correct
7 Correct 51 ms 9152 KB Output is correct
8 Correct 66 ms 10288 KB Output is correct
9 Correct 54 ms 8496 KB Output is correct
10 Correct 53 ms 8688 KB Output is correct
11 Correct 67 ms 10340 KB Output is correct
12 Correct 51 ms 9292 KB Output is correct
13 Correct 55 ms 8632 KB Output is correct
14 Correct 105 ms 11996 KB Output is correct
15 Correct 53 ms 10112 KB Output is correct
16 Correct 101 ms 13088 KB Output is correct
17 Correct 47 ms 8844 KB Output is correct
18 Correct 112 ms 12448 KB Output is correct
19 Correct 109 ms 12124 KB Output is correct
20 Correct 109 ms 12092 KB Output is correct
21 Correct 121 ms 12152 KB Output is correct
22 Correct 117 ms 12304 KB Output is correct
23 Correct 108 ms 12008 KB Output is correct
24 Correct 111 ms 12452 KB Output is correct
25 Correct 109 ms 12204 KB Output is correct
26 Correct 113 ms 12320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 8928 KB Output is correct
2 Correct 47 ms 8920 KB Output is correct
3 Correct 43 ms 9232 KB Output is correct
4 Correct 47 ms 8964 KB Output is correct
5 Correct 73 ms 10196 KB Output is correct
6 Correct 53 ms 8792 KB Output is correct
7 Correct 51 ms 9152 KB Output is correct
8 Correct 66 ms 10288 KB Output is correct
9 Correct 54 ms 8496 KB Output is correct
10 Correct 53 ms 8688 KB Output is correct
11 Correct 67 ms 10340 KB Output is correct
12 Correct 51 ms 9292 KB Output is correct
13 Correct 55 ms 8632 KB Output is correct
14 Correct 105 ms 11996 KB Output is correct
15 Correct 53 ms 10112 KB Output is correct
16 Correct 101 ms 13088 KB Output is correct
17 Correct 47 ms 8844 KB Output is correct
18 Correct 112 ms 12448 KB Output is correct
19 Correct 109 ms 12124 KB Output is correct
20 Correct 109 ms 12092 KB Output is correct
21 Correct 121 ms 12152 KB Output is correct
22 Correct 117 ms 12304 KB Output is correct
23 Correct 108 ms 12008 KB Output is correct
24 Correct 111 ms 12452 KB Output is correct
25 Correct 109 ms 12204 KB Output is correct
26 Correct 113 ms 12320 KB Output is correct
27 Correct 242 ms 29548 KB Output is correct
28 Correct 134 ms 12900 KB Output is correct
29 Correct 111 ms 13584 KB Output is correct
30 Correct 103 ms 11668 KB Output is correct
31 Correct 203 ms 25068 KB Output is correct
32 Correct 204 ms 33316 KB Output is correct
33 Correct 209 ms 33076 KB Output is correct
34 Correct 228 ms 27644 KB Output is correct
35 Correct 213 ms 33448 KB Output is correct
36 Correct 203 ms 33412 KB Output is correct
37 Correct 272 ms 33224 KB Output is correct
38 Correct 186 ms 24856 KB Output is correct
39 Correct 167 ms 25196 KB Output is correct