Lara Croft, the fiercely independent daughter of a missing adventurer, must push herself beyond her limits when she discovers the island where her father disappeared. In this mysterious island, Lara finds a tomb with a very heavy door. To open the do…
上次周赛碰到这个题目,居然都没思路,真是不应该啊,起码也应该想到枚举法. 因为题目只允许每一row进行reverse操作,而每两列可以进行交换操作,所以首先把row的变化固定下来,即枚举第一列与第1-m列进行交换,之后逐个检查每一行第一列的状态 与 终态是否一致,不一致的话则该行就一定要进行reverse操作了,这样下来,每次枚举就把row的reverse变化给固定下来,接下来只要枚举 接下来的2-m行互相的列变换即可,只需一个嵌套循环即可,总的循环也只是三重 而n和m仅有100,规模承担的起…
传送门 Description 给你一个0/1矩阵,可以将矩阵中的0变成1,问最少经过多少此操作使得矩阵任意一元素四周的元素和为偶数. Input 第一行是一个整数T代表数据组数,每组数据包含以下内容: 第一行是一个整数n,代表矩阵的行列数 接下来n行每行n个用空格隔开的整数,代表矩阵元素. Output 对于每组数据输出一行,格式为Case X: ans Sample Input Sample Output Case : Case : Case : - Hint 1≤n≤15,数据不超过30组…
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2459 题意:给个n*n的01矩阵,可以修改其中的0变成1,问最少修改几个0可以让所有位置中的上下左右的数字和为偶数. 枚举第一行,第二行可以递推得到,所以只需要2^n枚举,外加n*n的判断. #include <bits/stdc++.h> using namespa…
Fliptile Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 14297   Accepted: 5257 Description Farmer John knows that an intellectually satisfied cow is a happy cow who will give more milk. He has arranged a brainy activity for cows in whic…
题目传送门 /* 题意:求最少改变多少个0成1,使得每一个元素四周的和为偶数 状态压缩+枚举:枚举第一行的所有可能(1<<n),下一行完全能够由上一行递推出来,b数组保存该位置需要填什么 最后检查不同的数量,取最小值 */ #include <cstdio> #include <algorithm> #include <cstring> using namespace std; ; const int INF = 0x3f3f3f3f; int a[MAXN…
#点击传送 题目描述 Recently Vasya found a golden ticket - a sequence which consists of nn digits a1a2-ana1a2-an. Vasya considers a ticket to be lucky if it can be divided into two or more non-intersecting segments with equal sums. For example, ticket 3501783…
枚举每个格子的状态显然是不可能的. 思考发现,矩阵第一行的状态确定以后,下面的状态都可以递推出来. 于是状压枚举第一行的状态,递推全图的状态并判定是否可行. /*by SilverN*/ #include<iostream> #include<algorithm> #include<cstring> #include<cstdio> #include<cmath> #include<list> using namespace std;…
题目描述 Farmer John has bought property in the Caribbean and is going to try to raise dairy cows on a big farm composed of islands. Set in his ways, he wants to surround all the islands with fence. Each island in the farm has the shape of a polygon. He…
问题描述 UVA11464 题解 第一直觉爆搜. 发现 \(N \le 15\) ,然后后面每行都可以通过第一行递推出来. 爆搜第一行,递推后面+check \(\mathrm{Code}\) #include<bits/stdc++.h> using namespace std; template <typename Tp> void read(Tp &x){ x=0;char ch=1;int fh; while(ch!='-'&&(ch>'9'|…