예제)
. . X . .
. . X . .
XXXXX
. . X . .
. . X . .
이 경우 누울 장소가 8 8로 주어져야 한다
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
using System.IO;
using System.Text;
using System.Linq;
using System.Reflection.PortableExecutable;
using System.Security.Cryptography;
namespace 연습장
{
internal class Program
{
static StringBuilder sb = new StringBuilder();
static void Main(string[] args)
{
using var reader = new StreamReader(Console.OpenStandardInput());
using var print = new StreamWriter(Console.OpenStandardOutput());
_1652_boj boj = new _1652_boj();
boj.boj_1652();
}
}
internal class _1652_boj
{
public void boj_1652()
{
int n = int.Parse(Console.ReadLine());
int x = 0, y = 0;
string[] room = new string[n];
for (int i =0; i < n; i++)
room[i] = Console.ReadLine();
for (int i = 0; i < n; i++)
{
int space = 0;
for (int j = 0; j < n; j++)
{
if (room[i][j] == '.')
{
space++;
if (space == 2)
x++;
}
else
space = 0;
}
}
for (int i = 0; i < n; i++)
{
int space = 0;
for (int j = 0; j < n; j++)
{
if (room[j][i] == '.')
{
space++;
if (space == 2)
y++;
}
else
space = 0;
}
}
Console.WriteLine(x + " " + y);
}
}
}
|
cs |
문제 자체가 한번에 이해할 수 있기 보다는 깊게 생각을 해보고 예외적인 상황을 생각해봐야하는 문제인것 같다.