728x90
ํ๋ฌธ..
๋ฐ๋ณต๋ฌธ ์์ ๋ณ์ 2๊ฐ ๋ฃ๋๊ฑฐ ์ฒ์ ํด๋ดใ ใ ์ด์ค๋ฐ๋ณต๋ฌธ๋ณด๋ค ๊น๋ํ๊ธด ํ๋ค
๊ฐ๋ก ๊ฐฏ์ ๊ตฌํ๊ณ , ์ธ๋ก ๊ฐฏ์ ๊ตฌํด์ ๋ํ๊ธฐ
๋์ ํ์ด
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(int argc, char** argv)
{
int test_case;
int len = 0;
char c;
//freopen("input.txt", "r", stdin);
for (test_case = 1; test_case <= 10; ++test_case)
{
int answer = 0;
vector<string> map;
cin >> len;
for (int i = 0; i < 8; ++i){
string c;
cin >> c;
map.push_back(c);
}
for (int i = 0; i < 8; ++i){
for (int j = 0; j <= 8 - len; ++j)
{
int s, e;
for (s = j, e = j + len - 1; s <= e; ++s, --e)
{
if (map[i][s] != map[i][e])
break;
}
if (s >= e)
answer++;
for (s = j, e = j + len - 1; s <= e; ++s, --e)
{
if(map[s][i] != map[e][i])
break;
}
if (s >= e)
answer++;
}
}
cout << "#" << test_case << " " << answer << "\n";
}
return 0;
}
728x90
'๐ ์๊ณ ๋ฆฌ์ฆ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[C++/SWEA] 1208. [S/W ๋ฌธ์ ํด๊ฒฐ ๊ธฐ๋ณธ] 1์ผ์ฐจ - Flatten (D3) (0) | 2024.11.16 |
---|---|
[C++/SWEA] 1859. ๋ฐฑ๋ง ์ฅ์ ํ๋ก์ ํธ (D2) (0) | 2024.11.16 |
[C++/SWEA] 21425. += (D2) (0) | 2024.11.16 |
[C++/SWEA] 1206. [S/W ๋ฌธ์ ํด๊ฒฐ ๊ธฐ๋ณธ] 1์ผ์ฐจ - View (D3) (0) | 2024.11.16 |