题意:一个n * m的矩阵,求从左上走到右下经过的数异或和为k的方案数。

题解:

  因为数据范围较小,所以我们可以采用meet in the middle过掉此题、、、

  然而define inf LL 才过。。。。

 #include<bits/stdc++.h>
using namespace std;
#define R register int
#define AC 22
#define LL long long
#define int LL int n, m;
LL k, ans;
LL s[AC][AC]; map<int, LL> Map[AC]; inline LL read()
{
LL x = ;char c = getchar();
while(c > '' || c < '') c = getchar();
while(c >= '' && c <= '') x = x * 10ll + c - '', c = getchar();
return x;
} void pre()
{
n = read(), m = read(), k = read();
for(R i = ; i <= n; i ++)
for(R j = ; j <= m; j ++) s[i][j] = read();
} void dfs1(int x, int y, LL now)//从左上角开始往对角线搜
{
if(x < || x > n || y < || y > m) return ;
if(x + y == (n + m + ) / ) {++ Map[x][now]; return;}
dfs1(x + , y, now ^ s[x + ][y]);
dfs1(x, y + , now ^ s[x][y + ]);
} void dfs2(int x, int y, LL now)//从右下角开始往对角线搜
{
if(x < || x > n || y < || y > m) return ;
if(x + y == (n + m + ) / ) {ans += Map[x][now ^ s[x][y]]; return ;}//不能把同一个数异或2次。
dfs2(x - , y, now ^ s[x - ][y]);
dfs2(x, y - , now ^ s[x][y - ]);
} signed main()
{
freopen("in.in", "r", stdin);
pre();
dfs1(, , s[][]);
dfs2(n, m, k ^ s[n][m]);//因为x ^ y = k ----> x ^ k = y
printf("%lld\n", ans);
fclose(stdin);
return ;
}

CF#498 1006F Xor-Paths的更多相关文章

  1. CF Gym 102028G Shortest Paths on Random Forests

    CF Gym 102028G Shortest Paths on Random Forests 抄题解×1 蒯板子真jir舒服. 构造生成函数,\(F(n)\)表示\(n\)个点的森林数量(本题都用E ...

  2. [CodeForces]1006F Xor Path

    双向搜索. 水div3的时候最后一道题由于C题死活看不懂题 来不及做F了Orz.. 因为n,m是20,双向搜索一下,求个到中间的Xor值的方案,统计一下即可. 时间复杂度\(O(2^{21})\) 好 ...

  3. cf 498 B. Name That Tune

    不会不会,,,%%http://hzwer.com/5813.html #include<cstdio> #include<iostream> #include<algo ...

  4. Codeforces Round #498 (Div. 3) 简要题解

    [比赛链接] https://codeforces.com/contest/1006 [题解] Problem A. Adjacent Replacements        [算法] 将序列中的所有 ...

  5. 旧书重温:0day2【5】shellcode变形记

    紧接上一篇,结合第一篇 //这篇文章主要成功溢出一个带有缓冲区溢出的小程序,其中我们的shellcode被strcpy截断了所以我们需要变形shellcode,这个实验中也出现了很多意想不到的拦路虎, ...

  6. CF 741D. Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths [dsu on tree 类似点分治]

    D. Arpa's letter-marked tree and Mehrdad's Dokhtar-kosh paths CF741D 题意: 一棵有根树,边上有字母a~v,求每个子树中最长的边,满 ...

  7. CF 979D Kuro and GCD and XOR and SUM(异或 Trie)

    CF 979D Kuro and GCD and XOR and SUM(异或 Trie) 给出q(<=1e5)个操作.操作分两种,一种是插入一个数u(<=1e5),另一种是给出三个数x, ...

  8. CF&&CC百套计划2 CodeChef December Challenge 2017 Chef And Easy Xor Queries

    https://www.codechef.com/DEC17/problems/CHEFEXQ 题意: 位置i的数改为k 询问区间[1,i]内有多少个前缀的异或和为k 分块 sum[i][j] 表示第 ...

  9. CF 741 D. Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths

    D. Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths http://codeforces.com/problemset/probl ...

随机推荐

  1. SIFT 特征点提取算法

    SIFT特征点相对于ORB计算速度较慢,在没有GPU加速情况下,无法满足视觉里程计的实时性要求,或者无法运行在手机平台上,但是效果更好,精度更高.在应用时可以择优选取,了解其本质原理的动机是为了自己使 ...

  2. Linux 下获取通讯IP

    #!/bin/sh # filename: get_net.sh default_route=$(ip route show) default_interface=$() address=$(ip a ...

  3. java 多维数组转化为字符串

    int[][] a = {{1,2,3},{4,5,7}}; System.out.println(Arrays.deepToString(a)); Arrays.deepToString()此方法是 ...

  4. Unity与服务区交互数据

    Unity与服务区交互数据 Unity可能在用的时候使用到登陆等需要与服务器交互数据.今天尝试使用了WWW类和WWWForm类来实现Get请求与Post请求. 1.WWW Unity圣典解释: WWW ...

  5. Pyhton网络爬虫实例_豆瓣电影排行榜_BeautifulSoup4方法爬取

    -----------------------------------------------------------学无止境------------------------------------- ...

  6. 【springmvc+mybatis项目实战】杰信商贸-1.项目背景

    1.项目背景杰信项目物流行业的项目,杰信商贸是国际物流行业一家专门从事进出口玻璃器皿贸易的公司.公司总部位于十一个朝代的帝王之都西安,业务遍及欧美.随着公司不断发展壮大,旧的信息系统已无法满足公司的快 ...

  7. [Clr via C#读书笔记]Cp7常量和字段

    Cp7常量和字段 常量 常量在编译的时候必须确定,只能一编译器认定的基元类型.被视为静态,不需要static:直接嵌入IL中: 区别ReadOnly 只能在构造的时候初始化,内联初始化. 字段 数据成 ...

  8. Appium ——Android KEYCODE键值:

    Python下语法: driver.keyevent(键值) 电话按键: 键名 描述 键值 KEYCODE_CALL 拨号键 5 KEYCODE_ENDCALL 挂机键 6 KEYCODE_HOME ...

  9. BOM / URL编码解码 / 浏览器存储

    BOM 浏览器对象模型 BOM(Browser Object Model) 是指浏览器对象模型,是用于描述这种对象与对象之间层次关系的模型,浏览器对象模型提供了独立于内容的.可以与浏览器窗口进行互动的 ...

  10. gdb超级基础教程

    GDB超级基础教程 为什么叫超级基础呢,因为我被坑了一把.... 编译选项带 -g 就可以在可执行程序中加入调试信息,然后就可以使用gdb去查看了. 使用help命令就可以看到: (gdb) help ...