-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2210.cpp
More file actions
58 lines (48 loc) · 925 Bytes
/
2210.cpp
File metadata and controls
58 lines (48 loc) · 925 Bytes
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
// 2210. 숫자판 점프
// 2021.10.27
// 브루트 포스
#include<iostream>
#include<set>
using namespace std;
int maps[5][5];
set<int> sets;
int dx[4] = { 0,0,1,-1 };
int dy[4] = { 1,-1,0,0 };
void go(int cnt, int x, int y, int num)
{
if (cnt == 6)
{
sets.insert(num);
return;
}
for (int i = 0; i < 4; i++)
{
int xx = x + dx[i];
int yy = y + dy[i];
if (xx < 0 || yy < 0 || xx >= 5 || yy >= 5)
{
continue;
}
int afterNum = num * 10 + maps[xx][yy];
go(cnt + 1, xx, yy, afterNum);
}
}
int main()
{
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 5; j++)
{
cin >> maps[i][j];
}
}
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 5; j++)
{
go(0, i, j, 0);
}
}
cout << sets.size() << endl;
return 0;
}