티스토리 뷰

알고리즘/SWEA

[SWEA 1216] 회문2

히더 2018. 8. 9. 15:34

출처 : https://www.swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV14Rq5aABUCFAYi


#include <iostream>

#include <algorithm>

#include <memory.h>

using namespace std;


int result, N;

char arr[100][100];


void cal(int i, int sj, int ej, int l)

{

int zz = 1; int ll = l;

if (arr[i][sj] == arr[i][ej])

{

while (1)

{

if (arr[i][sj + zz] != arr[i][ej - zz]) break;


if (ll < 4)

{

result = max(result,l); break;

}

ll -= 2; zz++;

}

}

int zzz = 1; int lll = l;

if (arr[sj][i] == arr[ej][i])

{

while (1)

{

if (arr[sj+zzz][i] != arr[ej-zzz][i]) break;


if (lll < 4)

{

result = max(result, l); break;

}

lll -= 2; zzz++;

}

}

}


int main()

{

int T; int t;

T = 10;

while (T--)

{

cin >> t; result = 1;

for (int i = 0; i < 100; i++)for (int j = 0; j < 100; j++)cin >> arr[i][j];


for (int k = 0; k < 100; k++) for (int i = 0; i < 99; i++)for (int j = i + 1; j < 100; j++) cal(k, i, j, j - i + 1);


cout << "#" << t << " " << result << endl;

}


return 0;

}


'알고리즘 > SWEA' 카테고리의 다른 글

[SWEA 1218] 괄호 짝짓기  (0) 2018.08.10
[SWEA 1217] 거듭 제곱  (0) 2018.08.10
[SWEA 1215] 회문1  (0) 2018.08.09
[SWEA 1213] String  (0) 2018.08.09
[SWEA 1211] Ladder2  (0) 2018.08.06
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/02   »
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
글 보관함