Created
March 26, 2017 09:08
-
-
Save SF-Zhou/c296975ef3af0224d6a7b48c30976641 to your computer and use it in GitHub Desktop.
2017 Netease Distribute Work
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <cstdio> | |
#include <cstring> | |
#include <vector> | |
#include <queue> | |
#include <cmath> | |
#include <map> | |
#include <unordered_map> | |
using namespace std; | |
#define ff(i, n) for (int i = 0, END = (n); i < END; i ++) | |
#define fff(i, n, m) for (int i = (n), END = (m); i <= END; i ++) | |
#define dff(i, n, m) for (int i = (n), END = (m); i >= END; i --) | |
#define travel(e, first) for (int e = first, v = vv[first]; ~e; e = nxt[e], v = vv[e]) | |
#define clr(a, b) memset(a, b, sizeof(a)) | |
typedef long long ll; | |
int n, ans; | |
bool can[10][10]; | |
bool done[10]; | |
void input() { | |
ans = 0; | |
clr(can, 0); | |
clr(done, 0); | |
char s[10]; | |
fff (i, 1, n) { | |
scanf("%s", s); | |
ff (j, strlen(s)) { | |
char now = s[j]; | |
can[i][now - '0'] = 1; | |
} | |
} | |
} | |
void solve(int c) { | |
if (c == 0) { | |
ans ++; | |
return; | |
} | |
ff(i, 6) if (!done[i] && can[c][i]) { | |
done[i] = true; | |
solve(c - 1); | |
done[i] = false; | |
} | |
} | |
int main() { | |
while (scanf("%d", &n) == 1) { | |
input(); | |
solve(n); | |
printf("%d\n", ans); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment