CSES - Datatähti 2023 alku - Results
Submission details
Task:Lehmät
Sender:elias26
Submission time:2022-11-12 21:22:01 +0200
Language:Python3 (PyPy3)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
Test results
testverdicttimegroup
#1ACCEPTED0.04 s1, 2details
#20.04 s1, 2details
#3ACCEPTED0.04 s1, 2details
#40.04 s1, 2details
#50.04 s1, 2details
#60.05 s2details
#70.05 s2details
#80.05 s2details
#90.05 s2details

Code

from itertools import chain
hw = input().split(" ")
h = int(hw[0])
w = int(hw[1])
cowmap = [""] * h
for i in range(h):
cowmap[i] = input()
#first the upper bound:
startX = -1
startY = -1
endX = -1
endY = -1
for row in range(len(cowmap)):
found = cowmap[row].find('*')
if found == -1:
continue
else:
startX = found
startY = row
break
cowmap = cowmap[startY+1:]
for row in range(len(cowmap)):
cowmap[row] = cowmap[row][startX+1:]
#the ooperation on the next line
#only needs to be done one time, optimization?
endX = cowmap[0].find('*')-1
cowmap[row] = cowmap[row][:endX]
#finally, endY
for row in range(len(cowmap)-1,-1,-1):
if cowmap[row].find('*')==-1:
cowmap = cowmap[:row+1]
break
#TODO probably slow??
cowmap1d = []
for a in cowmap:
for b in a:
cowmap1d.append(b)
count = 0
for tile in cowmap1d:
if tile == '@':
count += 1
print(count)

Test details

Test 1

Group: 1, 2

Verdict: ACCEPTED

input
3 3
***
*.*
***

correct output
0

user output
0

Test 2

Group: 1, 2

Verdict:

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:

input
10 10
@@...@.@@@
..@@.@@..@
@.*******@
..*@....*.
...

correct output
11

user output
13

Test 5

Group: 1, 2

Verdict:

input
10 10
**********
*@@@@@@@@*
*@@@@@@@@*
*@@@@@@@@*
...

correct output
64

user output
56

Test 6

Group: 2

Verdict:

input
100 100
.........................@.......

correct output
60

user output
73

Test 7

Group: 2

Verdict:

input
100 100
..@@..........@......@....@@.....

correct output
1507

user output
1643

Test 8

Group: 2

Verdict:

input
100 100
.@..@@..@@.@..@..@..@@..@..@.....

correct output
3348

user output
3812

Test 9

Group: 2

Verdict:

input
100 100
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@...

correct output
7225

user output
8194