https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV14QpAaAAwCFAYi
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
int n;
int cnt = 0;
void check(string st) {
int j = n / 2;
for (int i = 0; i < j; i++) {
if (st[i] != st[(n-1) - i]) return;
}
cnt++;
}
int main() {
int sun = 0;
for (int i = 0; i < 10; i++) {
cnt = 0;
sun++;
cin >> n;
char arr[8][8];
for (int i = 0; i < 8; i++)
cin >> arr[i];
string tmp;
for (int i = 0; i < 8; i++) {
for (int j = 0; j <= 8 - n; j++) {
for (int x = j; x < j + n; x++) {
tmp += arr[i][x];
}
check(tmp);
tmp.clear();
}
}
for (int i = 0; i <= 8- n; i++) {
for (int j = 0; j < 8; j++) {
for (int x = i; x < i + n; x++) {
tmp += arr[x][j];
}
check(tmp);
tmp.clear();
}
}
cout << "#" << sun << " "<< cnt << endl;
}
return 0;
}
'APS > SWEA' 카테고리의 다른 글
1859. 백만 장자 프로젝트 C++ (0) | 2021.11.07 |
---|---|
1220. [S/W 문제해결 기본] 5일차 - Magnetic C++ (0) | 2021.08.30 |
1218. [S/W 문제해결 기본] 4일차 - 괄호 짝짓기 C++ (0) | 2021.08.27 |
1961. 숫자 배열 회전 C++ (0) | 2021.08.27 |
1209. [S/W 문제해결 기본] 2일차 - Sum C++ (0) | 2021.08.26 |