Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 3372 | Accepted: 2325 |
Descriptionios
Inputgit
Outputthis
Sample Inputspa
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1
Sample Outputcode
15
Hintblog
Sourceip
#include <iostream> #include <algorithm> #include <map> #include <vector> #include <functional> #include <string> #include <cstring> #include <queue> #include <set> #include <cmath> #include <cstdio> using namespace std; #define IOS ios_base::sync_with_stdio(false) #define TIE std::cin.tie(0) #define MIN2(a,b) (a<b?a:b) #define MIN3(a,b) (a<b?(a<c?a:c):(b<c?b:c)) #define MAX2(a,b) (a>b?a:b) #define MAX3(a,b,c) (a>b?(a>c?a:c):(b>c?b:c)) typedef long long LL; typedef unsigned long long ULL; const int INF = 0x3f3f3f3f; const double PI = 4.0*atan(1.0); int ans, board[10][10], a[10]; int dx[4] = { 1, -1, 0, 0 }, dy[4] = { 0, 0, 1, -1 }; map<int, int> ma; void dfs(int x, int y,int t) { a[t] = board[x][y]; if (t == 5){ int tmp = 0; for (int i = 0; i < 6; i++){ tmp *= 10; tmp += a[i]; } if (!ma.count(tmp)){ ma[tmp] = 1; ans++; } return; } for (int i = 0; i < 4; i++){ int nx = x + dx[i], ny = y + dy[i]; if (0 <= nx && nx < 5 && 0 <= ny && ny < 5) dfs(nx, ny, t + 1); } } int main() { for (int i = 0; i < 5; i++) for (int j = 0; j < 5; j++) scanf("%d", &board[i][j]); ans = 0; for (int i = 0; i < 5; i++) for (int j = 0; j < 5; j++) dfs(i, j, 0); printf("%d\n", ans); }