Task: | Lehmät |
Sender: | Septicuss |
Submission time: | 2022-10-31 02:31:39 +0200 |
Language: | Java |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.07 s | 1, 2 | details |
#2 | WRONG ANSWER | 0.07 s | 1, 2 | details |
#3 | ACCEPTED | 0.07 s | 1, 2 | details |
#4 | ACCEPTED | 0.07 s | 1, 2 | details |
#5 | WRONG ANSWER | 0.07 s | 1, 2 | details |
#6 | ACCEPTED | 0.08 s | 2 | details |
#7 | ACCEPTED | 0.07 s | 2 | details |
#8 | ACCEPTED | 0.07 s | 2 | details |
#9 | ACCEPTED | 0.07 s | 2 | details |
Code
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.math.BigInteger; import java.util.StringTokenizer; public class B430 { public static void main(String[] args) { FastReader reader = new FastReader(); PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out)); int n = reader.nextInt(); int m = reader.nextInt(); int cows = 0; boolean inside = false; for (int i = 0; i < n; i++) { String row = reader.nextLine(); if (!row.contains("*")) continue; for (int j = 0; j < m; j++) { char c = row.charAt(j); if (c == '.') continue; char prev = j == 0 ? 'x' : row.charAt(j - 1); char next = j + 1 == m ? 'x' : row.charAt(j + 1); if (c == '@' && inside) { cows++; continue; } if (c == '*') { if (!inside && (prev == '.' || prev == '@') && (next == '.' || next == '@')) inside = true; else inside = false; } } } reader.close(); writer.println(cows); writer.flush(); writer.close(); } static class FastReader { private BufferedReader br; private StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } void close() { try { br.close(); } catch (IOException e) { e.printStackTrace(); } st = null; br = null; } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } int nextInt() { return Integer.parseInt(next()); } BigInteger nextBigInteger() { return new BigInteger(next()); } double nextDouble() { return Double.parseDouble(next()); } long nextLong() { return Long.parseLong(next()); } } }
Test details
Test 1
Group: 1, 2
Verdict: ACCEPTED
input |
---|
3 3 *** *.* *** |
correct output |
---|
0 |
user output |
---|
0 |
Test 2
Group: 1, 2
Verdict: WRONG ANSWER
input |
---|
3 3 *** *@* *** |
correct output |
---|
1 |
user output |
---|
0 |
Test 3
Group: 1, 2
Verdict: ACCEPTED
input |
---|
5 10 ...@...... ..******.. @.*@@@@*.@ ..******.. ... |
correct output |
---|
4 |
user output |
---|
4 |
Test 4
Group: 1, 2
Verdict: ACCEPTED
input |
---|
10 10 @@...@.@@@ ..@@.@@..@ @.*******@ ..*@....*. ... |
correct output |
---|
11 |
user output |
---|
11 |
Test 5
Group: 1, 2
Verdict: WRONG ANSWER
input |
---|
10 10 ********** *@@@@@@@@* *@@@@@@@@* *@@@@@@@@* ... |
correct output |
---|
64 |
user output |
---|
0 |
Test 6
Group: 2
Verdict: ACCEPTED
input |
---|
100 100 .........................@....... |
correct output |
---|
60 |
user output |
---|
60 |
Test 7
Group: 2
Verdict: ACCEPTED
input |
---|
100 100 ..@@..........@......@....@@..... |
correct output |
---|
1507 |
user output |
---|
1507 |
Test 8
Group: 2
Verdict: ACCEPTED
input |
---|
100 100 .@..@@..@@.@..@..@..@@..@..@..... |
correct output |
---|
3348 |
user output |
---|
3348 |
Test 9
Group: 2
Verdict: ACCEPTED
input |
---|
100 100 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@... |
correct output |
---|
7225 |
user output |
---|
7225 |