hdu 4068 枚举 SanguoSHA
来源:互联网 发布:淘宝网新款女鞋 编辑:程序博客网 时间:2024/05/04 07:17
暴力枚举。代码能力有待提高,比赛的时候老是敲错,多敲题。我要! 加油!!!Lin!!!
/*Pro: 0Sol:date:*/#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>#include <cmath>#include <queue>#include <set>#include <map>#include <vector>using namespace std;int t,n;string people[10];map <string , int> mp;int a[10],b[10];bool grid[10][10];int main(){ scanf("%d",&t); for(int ca = 1; ca <= t; ca ++){ scanf("%d",&n); mp.clear(); memset(grid,false,sizeof(grid)); for(int i = 1; i <= n;i ++) cin >> people[i]; sort(people + 1, people + 1 + n); for(int i = 1; i <= n; i ++) mp[people[i]] = i; for(int i = 1; i <= n; i ++){ int k; char name[20]; scanf("%d",&k); while(k --){ scanf("%s",name); grid[i][mp[name]] = true;// a can defeat b } } for(int i = 1; i <= n; i ++) a[i] = i; bool flag ; do{ //for every a sequence for(int j = 1; j <= n; j ++) b[j] = j; flag = true; do{ int pa = 1; int pb = 1; while(pa <= n && pb <= n){ if(grid[b[pb]][a[pa]]) // b can defeat a pa ++; else pb ++; } if(pa > n) flag = false;// i lose once, then this sequence is not the answer }while(next_permutation(b + 1, b + 1 + n)); if(flag) break;//represents that a all wins }while(next_permutation(a + 1, a + 1 + n));// for(int i = n; i > 1; i --)// printf("%d ",a[i]); printf("%d\n",a[1]); printf("Case %d: ",ca); if(flag) { printf("Yes\n"); for(int i = 1; i < n; i++) printf("%s ",people[a[i]].c_str()); printf("%s\n",people[a[n]].c_str()); }else printf("No\n"); }return 0;}
- hdu 4068 枚举 SanguoSHA
- SanguoSHA - HDU 4068 暴力枚举
- hdu 4068 SanguoSHA
- HDU-4068-SanguoSHA
- HDU 4068 SanguoSHA
- hdu 4068 SanguoSHA——11年福州网络赛水题
- SanguoSHA
- sanguosha code
- hdu 3332 暴力枚举
- hdu 4007 枚举 Dave
- hdu 1015 Safecracker(枚举)
- hdu 1087 枚举+DP
- hdu 1158 枚举+DP
- hdu-1425(排序||枚举)
- HDU 4353 枚举
- HDU 3823 暴力枚举
- HDU 4380 预处理枚举
- hdu 4334 Trouble 枚举。。。。
- 占位
- 时序图学习
- Windows程式开发设计指南--Unicode简介
- 【经验教训】Broken pipe等
- 半年总结
- hdu 4068 枚举 SanguoSHA
- Windows程式开发设计指南--视窗和讯息
- :婚姻是一种妥协的艺术
- 给大学生的忠告
- Windows程式开发设计指南--输出文字
- 看十遍不如用一遍
- Windows程式开发设计指南--图形基础
- android常用单位
- 解决Backup Exec备份Windows 2008操作系统出现"带异常的成功"问题