USACO sec1.5 Checker Challenge
2012-08-21 11:32
447 查看
八皇后问题,最大输入13,单case,时限1s;
和 HDOJ 不同的是:
Do not precalculate the value and print it (or even find a formula for it); that's cheating. Work on your program until it can solve the problem properly. If you insist on cheating, your login to the USACO training pages will be removed and you will be disqualified from all USACO competitions. YOU HAVE BEEN WARNED.
( 不知道真的假的)
和 HDOJ 不同的是:
Do not precalculate the value and print it (or even find a formula for it); that's cheating. Work on your program until it can solve the problem properly. If you insist on cheating, your login to the USACO training pages will be removed and you will be disqualified from all USACO competitions. YOU HAVE BEEN WARNED.
( 不知道真的假的)
/* PROG : checker LANG : C++ */ # include <stdio.h> # include <string.h> # define N 15 int k, n = 0, m = 3; /********************************/ int sol ; char vis[3][3*N]; void dfs(int cnt) { int i, j; if (cnt == k) { ++n; if (m) { --m; printf("%d", sol[1]); for (i = 2; i <= k; ++i) printf(" %d", sol[i]); putchar('\n'); } } else for (i = 1; i <= k; ++i) if (!vis[0][i] && !vis[1][cnt+i] && !vis[2][cnt-i+k]) { vis[0][i] = vis[1][cnt+i] = vis[2][cnt-i+k] = 1; sol[cnt+1] = i; dfs(cnt+1); vis[0][i] = vis[1][cnt+i] = vis[2][cnt-i+k] = 0; } } /********************************/ void solve(void) { scanf("%d", &k); memset(vis, 0, sizeof(vis)); dfs(0); printf("%d\n", n); } int main() { freopen("checker.in", "r", stdin); freopen("checker.out", "w", stdout); solve(); fclose(stdin); fclose(stdout); return 0; }
相关文章推荐
- USACO-cha1-sec1.5 Checker Challenge
- USACO section 1.5 Checker Challenge(dfs深搜)
- USACO1.5 Checker Challenge(类n皇后问题)
- USACO 1.5 Checker Challenge
- USACO 1.5 Checker Challenge(DFS)
- USACO 1.5 Checker Challenge (DFS)
- USACO 1.5 Checker Challenge
- USACO 1.5 Checker Challenge (DFS + 剪枝)
- [usaco]1.5 Checker Challenge
- USACO 1.5 Checker Challenge (位操作)
- USACO 1.5 Checker Challenge (checker)
- USACO Section 1.5 Checker Challenge - 普普通通的皇后问题~~
- USACO section 1.5 Checker Challenge(dfs深搜)
- usaco Section 1.5 Checker Challenge 最慢0.162秒0.0+n皇后问题位运算版(C语言)
- USACO 1.4 Checker Challenge 位运算
- USACO Section 1.5: Prob Checker Challenge
- USACO 1.5.4 Checker Challenge
- USACO Section 1.5 Checker Challenge
- usaco6.5.5 Checker Challenge
- Section 1.5 Checker Challenge