본문 바로가기

Problem/ETC

[SW Expert Academy] 1215. 회문1

[SW Expert Academy]1215. 회문1




문제 링크 : https://www.swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV14QpAaAAwCFAYi




나의 코드




Github : https://github.com/j2wooooo/Daliy_Algorithms/blob/master/Daliy_Algorithms/SW_Expert_Academy_1215/SW_Expert_Academy_1215.cpp




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
// SW Expert Academy 1215. 회문1 
#include<iostream>
#include<string>
using namespace std;
 
int N, ans;
char map[8][8];
string str;
 
int main(void)
{
    bool flag = true;
 
    for(int T = 1; T <= 10; T++)
    {
        ans = 0;
        cin >> N;
        getline(cin, str);
 
        for (int i = 0; i < 8; i++) {
            for (int j = 0; j < 8; j++)
            {
                cin >> map[i][j];
            }
        }
 
        // 가로 탐색
        for (int i = 0; i < 8; i++)
        {
            for (int n = 0; n <= 8 - N; n++)
            {
                flag = true;
                for (int j = 0; j < (N / 2); j++)
                {
                    if (map[i][j+n] != map[i][N +- j - 1]) flag = false;
                }
                if (flag)ans++;
            }
        }
 
        // 세로 탐색
        for (int i = 0; i < 8; i++)
        {
            for (int n = 0; n <= 8 - N; n++)
            {
                flag = true;
                for (int j = 0; j < (N / 2); j++)
                {
                    if (map[j+n][i] != map[N+- j - 1][i]) flag = false;
                }
                if (flag) ans++;
            }
        }
 
        cout << '#' << T << ' ' << ans << '\n';
    }
    return 0;
}
cs


'Problem > ETC' 카테고리의 다른 글

[C/C++] BOJ 1158 :: 조세퍼스 문제  (0) 2019.03.08
[SW Expert Academy] 1216. 회문2  (0) 2019.03.06
[C/C++] BOJ 5525 :: IOIOI  (0) 2019.03.05
[SW Expert Academy] 1213. String  (0) 2019.03.05
[C/C++] BOJ 2163 :: 초콜릿 자르기  (0) 2019.02.21