백준 온라인 저지/브루트 포스2
3085번_사탕 게임
King94
2020. 1. 5. 14:32
문제 출처 : https://www.acmicpc.net/problem/3085
<C++code>
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
70
71
72
73
74
75
76
77
78
|
#include<iostream>
#include<vector>
using namespace std;
int n;
int size(vector<string> &rhs)
{ int maxs=1;
for(int i=0;i<n;i++)
{
int cnt=1;
for(int j=1;j<n;j++)
{
if(rhs[i][j]==rhs[i][j-1])
{
cnt+=1;
}
else
{
cnt=1;
}
if(maxs<cnt) maxs=cnt;
}
cnt=1;
for(int j=1;j<n;j++)
{
if(rhs[j][i]==rhs[j-1][i])
{
cnt+=1;
}
else
{
cnt=1;
}
if(maxs<cnt) maxs=cnt;
}
}
return maxs;
}
int main(void)
{
//int n;
cin>>n;
vector<string> a(n);
for(int i=0;i<n;i++)
{
cin>>a[i];
}
int maxs=0;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(j+1<n)
{
swap(a[i][j],a[i][j+1]);
int temp=size(a);
if(maxs<temp) maxs=temp;
swap(a[i][j],a[i][j+1]);
}
if(i+1<n)
{
swap(a[i][j],a[i+1][j]);
int temp=size(a);
if(maxs<temp)maxs=temp;
swap(a[i][j],a[i+1][j]);
}
}
}
cout<<maxs<<endl;
return 0;
}
|
cs |