Skip to content

Commit 1daf675

Browse files
committed
[Bronze IV] Title: 체스 초보 브실이, Time: 36 ms, Memory: 32412 KB -BaekjoonHub
1 parent a0f97b9 commit 1daf675

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# [Bronze IV] 체스 초보 브실이 - 29725
2+
3+
[문제 링크](https://www.acmicpc.net/problem/29725)
4+
5+
### 성능 요약
6+
7+
메모리: 32412 KB, 시간: 36 ms
8+
9+
### 분류
10+
11+
구현
12+
13+
### 제출 일자
14+
15+
2024년 12월 19일 11:04:06
16+
17+
### 문제 설명
18+
19+
<p>브실이는 이제 막 체스에 입문한 체스 초보이다. 브실이는 아직 초보이기 때문에 체스판의 기물 점수 계산을 잘하지 못한다.</p>
20+
21+
<p>체스판의 기물 점수는 백의 기물 점수 합에서 흑의 기물 점수 합을 뺀 값이고, 기물에 해당하는 킹, 폰, 나이트, 비숍, 룩, 퀸의 기물 점수는 각각 <mjx-container class="MathJax" jax="CHTML" style="font-size: 104.6%; position: relative;"><mjx-math class="MJX-TEX" aria-hidden="true"><mjx-mn class="mjx-n"><mjx-c class="mjx-c30"></mjx-c></mjx-mn></mjx-math><mjx-assistive-mml unselectable="on" display="inline"><math xmlns="http://www.w3.org/1998/Math/MathML"><mn>0</mn></math></mjx-assistive-mml><span aria-hidden="true" class="no-mathjax mjx-copytext">$0$</span></mjx-container>, <mjx-container class="MathJax" jax="CHTML" style="font-size: 104.6%; position: relative;"><mjx-math class="MJX-TEX" aria-hidden="true"><mjx-mn class="mjx-n"><mjx-c class="mjx-c31"></mjx-c></mjx-mn></mjx-math><mjx-assistive-mml unselectable="on" display="inline"><math xmlns="http://www.w3.org/1998/Math/MathML"><mn>1</mn></math></mjx-assistive-mml><span aria-hidden="true" class="no-mathjax mjx-copytext">$1$</span></mjx-container>, <mjx-container class="MathJax" jax="CHTML" style="font-size: 104.6%; position: relative;"><mjx-math class="MJX-TEX" aria-hidden="true"><mjx-mn class="mjx-n"><mjx-c class="mjx-c33"></mjx-c></mjx-mn></mjx-math><mjx-assistive-mml unselectable="on" display="inline"><math xmlns="http://www.w3.org/1998/Math/MathML"><mn>3</mn></math></mjx-assistive-mml><span aria-hidden="true" class="no-mathjax mjx-copytext">$3$</span></mjx-container>, <mjx-container class="MathJax" jax="CHTML" style="font-size: 104.6%; position: relative;"><mjx-math class="MJX-TEX" aria-hidden="true"><mjx-mn class="mjx-n"><mjx-c class="mjx-c33"></mjx-c></mjx-mn></mjx-math><mjx-assistive-mml unselectable="on" display="inline"><math xmlns="http://www.w3.org/1998/Math/MathML"><mn>3</mn></math></mjx-assistive-mml><span aria-hidden="true" class="no-mathjax mjx-copytext">$3$</span></mjx-container>, <mjx-container class="MathJax" jax="CHTML" style="font-size: 104.6%; position: relative;"><mjx-math class="MJX-TEX" aria-hidden="true"><mjx-mn class="mjx-n"><mjx-c class="mjx-c35"></mjx-c></mjx-mn></mjx-math><mjx-assistive-mml unselectable="on" display="inline"><math xmlns="http://www.w3.org/1998/Math/MathML"><mn>5</mn></math></mjx-assistive-mml><span aria-hidden="true" class="no-mathjax mjx-copytext">$5$</span></mjx-container>, <mjx-container class="MathJax" jax="CHTML" style="font-size: 104.6%; position: relative;"><mjx-math class="MJX-TEX" aria-hidden="true"><mjx-mn class="mjx-n"><mjx-c class="mjx-c39"></mjx-c></mjx-mn></mjx-math><mjx-assistive-mml unselectable="on" display="inline"><math xmlns="http://www.w3.org/1998/Math/MathML"><mn>9</mn></math></mjx-assistive-mml><span aria-hidden="true" class="no-mathjax mjx-copytext">$9$</span></mjx-container>점이다. </p>
22+
23+
<p>체스 초보 브실이를 위해 체스판의 기물 점수 계산을 도와주자! </p>
24+
25+
### 입력
26+
27+
<p>첫 번째 줄부터 <mjx-container class="MathJax" jax="CHTML" style="font-size: 104.6%; position: relative;"><mjx-math class="MJX-TEX" aria-hidden="true"><mjx-mn class="mjx-n"><mjx-c class="mjx-c38"></mjx-c></mjx-mn></mjx-math><mjx-assistive-mml unselectable="on" display="inline"><math xmlns="http://www.w3.org/1998/Math/MathML"><mn>8</mn></math></mjx-assistive-mml><span aria-hidden="true" class="no-mathjax mjx-copytext">$8$</span></mjx-container>개의 줄에 걸쳐 <mjx-container class="MathJax" jax="CHTML" style="font-size: 104.6%; position: relative;"><mjx-math class="MJX-TEX" aria-hidden="true"><mjx-mn class="mjx-n"><mjx-c class="mjx-c38"></mjx-c></mjx-mn><mjx-mo class="mjx-n" space="3"><mjx-c class="mjx-cD7"></mjx-c></mjx-mo><mjx-mn class="mjx-n" space="3"><mjx-c class="mjx-c38"></mjx-c></mjx-mn></mjx-math><mjx-assistive-mml unselectable="on" display="inline"><math xmlns="http://www.w3.org/1998/Math/MathML"><mn>8</mn><mo>×</mo><mn>8</mn></math></mjx-assistive-mml><span aria-hidden="true" class="no-mathjax mjx-copytext">$8\times8$</span></mjx-container> 크기의 체스판의 상태가 공백 없이 주어진다.</p>
28+
29+
<p>백의 기물은 영어 대문자, 흑의 기물은 영어 소문자로 주어진다.</p>
30+
31+
<p>입력으로 주어지는 문자열은 <span style="color:#e74c3c;"><code>.</code></span>, <span style="color:#e74c3c;"><code>K</code></span>, <span style="color:#e74c3c;"><code>k</code></span>, <span style="color:#e74c3c;"><code>P</code></span>, <span style="color:#e74c3c;"><code>p</code></span>, <span style="color:#e74c3c;"><code>N</code></span>, <span style="color:#e74c3c;"><code>n</code></span>, <span style="color:#e74c3c;"><code>B</code></span>, <span style="color:#e74c3c;"><code>b</code></span>, <span style="color:#e74c3c;"><code>R</code></span>, <span style="color:#e74c3c;"><code>r</code></span>, <span style="color:#e74c3c;"><code>Q</code></span>, <span style="color:#e74c3c;"><code>q</code></span>로만 이루어져 있고, 각각의 문자들은 다음을 뜻한다.</p>
32+
33+
<ul>
34+
<li><span style="color:#e74c3c;"><code>.</code></span>: 빈칸</li>
35+
<li><span style="color:#e74c3c;"><code>K</code></span> 또는 <span style="color:#e74c3c;"><code>k</code></span>: 킹</li>
36+
<li><span style="color:#e74c3c;"><code>P</code></span> 또는 <span style="color:#e74c3c;"><code>p</code></span>: 폰</li>
37+
<li><span style="color:#e74c3c;"><code>N</code></span> 또는 <span style="color:#e74c3c;"><code>n</code></span>: 나이트</li>
38+
<li><code><span style="color:#e74c3c;">B</span></code> 또는 <span style="color:#e74c3c;"><code>b</code></span>: 비숍</li>
39+
<li><span style="color:#e74c3c;"><code>R</code></span> 또는 <span style="color:#e74c3c;"><code>r</code></span>: 룩</li>
40+
<li><span style="color:#e74c3c;"><code>Q</code></span> 또는 <span style="color:#e74c3c;"><code>q</code></span>: 퀸</li>
41+
</ul>
42+
43+
### 출력
44+
45+
<p>주어진 체스판의 기물 점수를 출력한다.</p>
46+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# 킹, 폰, 나이트, 비숍, 룩, 퀸의 기물 점수는 각각 0, 1, 3, 3, 5, 9
2+
import sys
3+
4+
score = 0
5+
6+
for _ in range(8):
7+
line = sys.stdin.readline().strip()
8+
p = line.count('P') - line.count('p')
9+
n = line.count('N') - line.count('n')
10+
b = line.count('B') - line.count('b')
11+
r = line.count('R') - line.count('r')
12+
q = line.count('Q') - line.count('q')
13+
score = score + p + 3*n + 3*b + 5*r + 9*q
14+
15+
print(score)

0 commit comments

Comments
 (0)