搜索,没什么好说的。要注意读入。

Code:
 #include<cstdio>
#include<cstdlib>
using namespace std;
const int num[][]=
{{,,,,,,,,,},
{,,,,,,,,,},
{,,,,,,,,,},
{,,,,,,,,,},
{,,,,,,,,,},
{,,,,,,,,,},
{,,,,,,,,,},
{,,,,,,,,,},
{,,,,,,,,,},
{,,,,,,,,,}};
int map[][][][],vish[][],visl[][],visn[][],chess[][],h=,l=;
char s[];
void Read()
{
for(int k=;k<=;k++)
{
for(int j=;j<=;j++)
{
for(int i=;i<=;i++)
{
scanf("%s",s);
map[h][l][h][l-]= ( s[]=='>' ? - : );
scanf("%s",s);
map[h][l+][h][l]= ( s[]=='<' ? : - );
l+=;
}
for(int i=;i<=;i++)
{
scanf("%s",s);
map[h+][i][h][i]= ( s[]=='v' ? - : );
}
h++;l=;
}
for(int i=;i<=;i++)
{
scanf("%s",s);
map[h][l][h][l-]= ( s[]=='>' ? - : );
scanf("%s",s);
map[h][l+][h][l]= ( s[]=='<' ? : - );
l+=;
}
h++;l=;
}
}
void print()
{
for(int i=;i<=;i++)
{
for(int j=;j<;j++)
printf("%d ",chess[i][j]);
printf("%d\n",chess[i][]);
}
}
bool check(const int &X,const int &Y,const int &Val)
{
if(map[X][Y][X][Y-]==)
if(Val<=chess[X][Y-])return false;
if(map[X][Y][X][Y-]==-)
if(Val>=chess[X][Y-])return false;
if(map[X][Y][X-][Y]==)
if(Val<=chess[X-][Y])return false;
if(map[X][Y][X-][Y]==-)
if(Val>=chess[X-][Y])return false;
return true;
}
void dfs(int x,int y)
{
if(x==)
{
print();
exit();
}
for(int i=;i<=;i++)
if(!vish[x][i]&&!visl[y][i]&&!visn[num[x][y]][i])
if(check(x,y,i))
{
chess[x][y]=i;
vish[x][i]=visl[y][i]=visn[num[x][y]][i]=true;
if(y==)
dfs(x+,);
else
dfs(x,y+);
vish[x][i]=visl[y][i]=visn[num[x][y]][i]=false;
}
}
int main()
{
Read();
dfs(,);
return ;
}

【搜索】bzoj3109 [cqoi2013]新数独的更多相关文章

  1. BZOJ3109: [cqoi2013]新数独

    题目:http://www.lydsy.com/JudgeOnline/problem.php?id=3109 搜索一遍.读入注意一下.. #include<cstring> #inclu ...

  2. B3109 [cqoi2013]新数独 搜索dfs

    就是基于普通数独上的一点变形,然后就没什么了,普通数独就是进行一边dfs就行了. 题干: 题目描述 输入格式 输入一共15行,包含一个新数独的实例.第奇数行包含左右方向的符号(<和>),第 ...

  3. 3109. [CQOI2013]新数独【DFS】

    Description Input 输入一共15行,包含一个新数独的实例.第奇数行包含左右方向的符号(<和>),第偶数行包含上下方向的符号(^和v).   Output 输出包含9行,每行 ...

  4. CQOI2013 新数独

    传送门 这道题也是很暴力的搜索啊…… 因为数独一开始全是空的,只有许许多多的大小限制条件,那也没必要纠结从哪开始搜索了,直接暴力搜索之后判断一下是否合法. 这题最恶心的是读入.现学了一招判断点在哪个块 ...

  5. bzoj 3109: [cqoi2013]新数独

    #include<cstdio> #include<iostream> using namespace std; ][],li[][],xi[][],a[][],bh[][], ...

  6. bzoj 3109: [cqoi2013]新数独【dfs】

    按3x3的小块dfs,填数的时候直接满足所有条件即可 #include<iostream> #include<cstdio> #include<cstring> u ...

  7. bzoj3109【CQOI2013】新数独

    3109: [cqoi2013]新数独 Time Limit: 10 Sec  Memory Limit: 128 MB Submit: 365  Solved: 229 [Submit][Statu ...

  8. BZOJ3105: [cqoi2013]新Nim游戏 博弈论+线性基

    一个原来写的题. 既然最后是nim游戏,且玩家是先手,则希望第二回合结束后是一个异或和不为0的局面,这样才能必胜. 所以思考一下我们要在第一回合留下线性基 然后就是求线性基,因为要取走的最少,所以排一 ...

  9. BZOJ3105: [cqoi2013]新Nim游戏

    题解: 线性基?类似于向量上的基底. 此题题解戳这里:http://blog.csdn.net/wyfcyx_forever/article/details/39477673 代码: #include ...

随机推荐

  1. position的用法与心得

    position的四个属性值: relative absolute fixed static 为了便于理解,首先创建对应的div <div class="main"> ...

  2. 关于Linux下s、t、i、a权限

    文件权限除了r.w.x外还有s.t.i.a权限: 首先我们利用umask查看系统的权限为四位,首位就是特殊权限位,SetUID为4,SetGID为2,t为1 [root@iz2ze46xi6pjjj6 ...

  3. rdpClient

    https://github.com/jean343/RPI-GPU-rdpClient https://github.com/Nullstr1ng/MultiRDPClient.NET https: ...

  4. C# 读写XML文件示例

    using System; using System.Collections.Generic; using System.Text; using System.Configuration; using ...

  5. CNN中已知input_size、kernel_size、padding、stide计算output公式的理解

    在进行卷积运算和池化的时候,对于输入图像大小为input_size,给定kernel_size.padding.stride,计算得出output_size为: output_size =1+ (in ...

  6. LeetCode解题报告—— Longest Valid Parentheses

    Given a string containing just the characters '(' and ')', find the length of the longest valid (wel ...

  7. Container With Most Water——双指针

    Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai).  ...

  8. WebMail

    try { WebMail.SmtpServer = "smtp.example.com";      WebMail.SmtpPort = ;      WebMail.Enab ...

  9. ASP.NET MVC5(一)—— URL路由

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...

  10. spring mvc 表单提交 乱码

    1.在web.xml添加过滤器: <filter> <filter-name>SpringCharacterEncoding</filter-name> <f ...