POJ-3106 Flip and Turn (模拟)】的更多相关文章

题目地址:http://poj.org/problem?id=1753 /* 这题几乎和POJ 2965一样,DFS函数都不用修改 只要修改一下change规则... 注意:是否初始已经ok了要先判断 */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <cmath> #include <string> #i…
[题目大意] 给你一个n*m的矩阵,然后给你一系列操作,最后让你输出操作后的矩阵. 操作包括: 1:沿主对角线反转 2:沿副对角线反转 H:上下翻转 V:水平翻转 A B C:顺时针90° 180° 270° X Y Z:逆时针. 操作数量k<=100 000,n<=300. [分析] 直接暴力是O(k*n^2),TLE. 可以用一个2*2的矩阵,每一次对这个矩阵操作,最后在根据这个矩阵对所给矩阵进行同样的操作.复杂度O(4k).…
Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 37427   Accepted: 16288 Description Flip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16 squares. One side of each piece is white and the…
Maya Calendar Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 64795   Accepted: 19978 Description During his last sabbatical, professor M. A. Ya made a surprising discovery about the old Maya calendar. From an old knotted message, profes…
题目链接 题意 : 一个10×15的格子,有三种颜色的球,颜色相同且在同一片内的球叫做cluster(具体解释就是,两个球颜色相同且一个球可以通过上下左右到达另一个球,则这两个球属于同一个cluster,同时cluster含有至少两个球),每次选择cluster中包含同色球最多的进行消除,每次消除完之后,上边的要往下移填满空的地方,一列上的球移动之前与之后相对位置不变,如果有空列,右边的列往左移动,每一列相对位置不变 . 思路 : 模拟......不停的递归..... ////POJ 1027…
1.链接地址: http://bailian.openjudge.cn/practice/1753/ http://poj.org/problem?id=1753 2.题目: 总时间限制: 1000ms 内存限制: 65536kB 描述 Flip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16 squares. One side of each piece is wh…
Space Ant Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 3840   Accepted: 2397 Description The most exciting space discovery occurred at the end of the 20th century. In 1999, scientists traced down an ant-like creature in the planet Y19…
链接: http://poj.org/problem?id=3414 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22009#problem/J Pots Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8253   Accepted: 3499   Special Judge Description You are given two pots, havin…
https://vjudge.net/problem/POJ-1753 题意 4*4的棋盘,翻转其中的一个棋子,会带动邻接的棋子一起动.现要求把所有棋子都翻成同一种颜色,问最少需要几步. 分析 同一个棋子翻偶数次等于没有翻,翻奇数次就浪费步数,因此每个棋子最多翻一次,也就是说,答案最大就是16.故总状态数就是2^16,可以直接dfs暴力.还有另一种思路就是状态压缩,把棋盘压成16位的数字,翻转时采用异或操作,我们暴力枚举每个状态,即所有选择棋子的可能情况跑一遍,对于每一个棋子,对其能影响的位置可…
链接:poj 2632 题意:在n*m的房间有num个机器,它们的坐标和方向已知,现给定一些指令及机器k运行的次数, L代表机器方向向左旋转90°,R代表机器方向向右旋转90°,F表示前进,每次前进一米 若前进时机器i撞到机器j,输出"Robot i crashes into robot j " 若机器走出了n*m的房间,输出"Robot i crashes into the wall " 当出现上述情况.仅仅需输出第一次出现上述的情况 若全部指令运行完,全部机器都…
题目链接:http://poj.org/problem? id=1028 Description Standard web browsers contain features to move backward and forward among the pages recently visited. One way to implement these features is to use two stacks to keep track of the pages that can be rea…
题目链接:http://poj.org/problem?id=3087 题目大意:已知两堆牌s1和s2的初始状态, 其牌数均为c,按给定规则能将他们相互交叉组合成一堆牌s12,再将s12的最底下的c块牌归为s1,最顶的c块牌归为s2,依此循环下去. 现在输入s1和s2的初始状态 以及 预想的最终状态s12.问s1 s2经过多少次洗牌之后,最终能达到状态s12,若永远不可能相同,则输出"-1". 解题思路:照着模拟就好了,只是判断是否永远不能达到状态s12需要用map,定义map<…
链接: http://poj.org/problem?id=1068 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=27454#problem/B Parencodings Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 17044   Accepted: 10199 Description Let S = s1 s2...s2n be a well-forme…
Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 45691   Accepted: 19590 Description Flip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16 squares. One side of each piece is white and the…
看题传送门:http://poj.org/problem?id=1753 DFS枚举的应用. 基本上是参考大神的.... 学习学习.. #include<cstdio> #include<iostream> using namespace std; int n,s,d,ans; bool a[5][5],flag=false; //判断全部一样的情况 bool alllike() { for(int i=0;i<4;i++) for(int j=0;j<4;j++) i…
Flip Game   Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 52279   Accepted: 22018 Description Flip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16 squares. One side of each piece is white and th…
题目网址:http://poj.org/problem?id=1753 题目: Flip Game Description Flip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16 squares. One side of each piece is white and the other one is black and each piece is lying ei…
Flip Game Time Limit: 1000MS  Memory Limit: 65536K  Total Submissions: 4863  Accepted: 1983 Description Flip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16 squares. One side of each piece is white and the oth…
点击打开链接 Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 25674   Accepted: 11093 Description Flip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16 squares. One side of each piece is white a…
题意:给定一串字符,u表示是上坡,d表示下坡,f表示平坦的,每个有不同的花费时间,问你从开始走,最远能走到. 析:直接模拟就好了,没什么可说的,就是记下时间时要记双倍的,因为要返回来的. 代码如下: #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream> #include <cstring> #include…
题目:http://poj.org/problem?id=1753 因为粗心错了好多次……,尤其是把1<<15当成了65535: 参考博客:http://www.cnblogs.com/kuangbin/archive/2011/07/30/2121677.html 主要思想: 1.如果用一个4*4的数组存储每一种状态,不但存储空间很大,而且在穷举状态时也不方便记录.因为每一颗棋子都只有两种状态,所以可以用二进制0和1表示每一个棋子的状态,则棋盘的状态就可以用一个16位的整数唯一标识.而翻转的…
Description Flip game squares. One side of each piece is white and the other one is black and each piece is lying either it's black or white side up. Each round you flip 3 to 5 pieces, thus changing the color of their upper side from black to white a…
题目:http://poj.org/problem?id=1753 这个题在開始接触的训练计划的时候做过,当时用的是DFS遍历,其机制就是把每一个棋子翻一遍.然后顺利的过了.所以也就没有深究. 省赛前一次做PC2遇到了差点儿一模一样的题,仅仅只是是把棋盘的界限由4X4改为了5X5,然后一直跑不出结果来,可是当时崔老湿那个队过了,在最后总结的时候.崔老湿就说和这个题一样,只是要枚举第一行进行优化. 我以为就是恢复第一行然后第二行以此类推,只是手推一下结果是6不是4,就知道这个有问题. 问了崔老湿,…
题目地址链接:http://poj.org/problem?id=1753 题目大意: 有4*4的正方形,每个格子要么是黑色,要么是白色,当把一个格子的颜色改变(黑->白或者白->黑)时,其周围上下左右(如果存在的话)的格子的颜色也被反转,问至少反转几个格子可以使4*4的正方形变为纯白或者纯黑? 解题思路: 因为只有16个格子,且只有黑白两种状态,想到用一个二进制整数来表示棋盘的状态.首先你需要明白这个题目的两个性质——任何一个格子翻偶数次等同于不翻:翻格子的顺序对最终的结果是没有影响的,也就…
题目链接:http://poj.org/problem?id=3087 Description A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by starting with two stacks of poker chips, S1 and S2, each stack containing C chips. Each…
Description A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by starting with two stacks of poker chips, S1 and S2, each stack containing C chips. Each stack may contain chips of several…
题目链接 Description You, as a member of a development team for a new spell checking program, are to write a module that will check the correctness of given words using a known dictionary of all correct words in all their forms. If the word is absent in…
Description This puzzle consists of a random sequence of m black disks and n white disks on an oval-shaped track, with a turnstile capable of flipping (i.e., reversing) three consecutive disks. In Figure 1, there are 8 black disks and 10 white disks…
http://poj.org/problem?id=1753 题意:一个4*4的棋盘,只有黑和白两种棋子,每次翻转一个棋子,并且其四周的棋子也跟着翻转,求棋盘全为黑或全为白时所需的最少翻转次数. 思路:暴力枚举. 一共16个棋子,所以可以用二进制来存储.后来看了一下别人的代码,发现居然可以用异或运算来计算翻转情况,方便了不少. #include<iostream> #include<cstdio> #include<cstring> #include<queue&…
Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 26492   Accepted: 11422 Description Flip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16 squares. One side of each piece is white and the…