博客
关于我
习题 7-16 找座位(Finding Seats Again, UVa11846)
阅读量:310 次
发布时间:2019-03-03

本文共 753 字,大约阅读时间需要 2 分钟。

原题链接:

分类:回溯法
备注:模拟,水题

注意一下 不填字母的地方一定要是’.’,估计测试数据可能有填不满整个n*n块格子的情况。

#include
using namespace std;int n,k,num[25];char g[25][25],ans[25][25];inline char read(){ char ch=getchar(); while(ch==' '||ch=='\n')ch=getchar(); return ch;}inline bool check(int x,int y,int w,int h){ int cnt=0; for(int i=x;i
1)return false; if(g[i][j]-'0'!=w*h)return false; } } return cnt==1;}bool dfs(int pos,int now){ if(now==k)return true; while(isalpha(ans[pos/n][pos%n]))pos++; for(int w=1;w<=9;w++) for(int h=1;h<=9;h++){ if(w*h>9)continue; int x=pos/n,y=pos%n; if(x+h>n||y+w>n)break; if(check(x,y,w,h)){ for(int i=x;i

转载地址:http://epel.baihongyu.com/

你可能感兴趣的文章
mysql共享锁与排他锁
查看>>
MySQL内存表使用技巧
查看>>
MySQL再叙(体系结构、存储引擎、索引、SQL执行过程)
查看>>
mysql出现错误的解决办法
查看>>
MySQL函数
查看>>
mysql函数汇总之字符串函数
查看>>
mysql函数汇总之数学函数
查看>>
mysql函数汇总之日期和时间函数
查看>>
mysql函数汇总之条件判断函数
查看>>
mysql函数汇总之系统信息函数
查看>>
MySQL函数简介
查看>>
mysql函数遍历json数组
查看>>
MySQL函数(转发)
查看>>
mysql分区表
查看>>
MySQL分层架构与运行机制详解
查看>>
mysql分库分表中间件简书_MySQL分库分表
查看>>
MySQL分库分表会带来哪些问题?分库分表问题
查看>>
MySQL分组函数
查看>>
MySQL分组查询
查看>>
Mysql分表后同结构不同名称表之间复制数据以及Update语句只更新日期加减不更改时间
查看>>