Codeforces 294D - Shaass and Painter Robot】的更多相关文章

294D - Shaass and Painter Robot 思路: 可以用数学归纳法证明一个结论:整个棋盘黑白相间当且仅当边缘黑白相间. 分奇偶讨论又可得出边缘黑色格个数为n+m-2 这样就可以暴力模拟. 数组开不下保存边缘块有没有被访问,可以用map. 代码: #include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mem(a,b) memset(a,b,…
题目链接:http://codeforces.com/problemset/problem/752/C time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Santa Claus has Robot which lives on the infinite grid and can move along its lines. He…
/////////////////////////////////////////////////////////////////////////////////////////////////////// 作者:stxy-ferryman声明:本文遵循以下协议自由转载-非商用-非衍生-保持署名|Creative Commons BY-NC-ND 3.0 查看本文更新与讨论请点击:http://www.cnblogs.com/stxy-ferryman/链接被删请百度:stxy-ferryman…
题目链接:http://codeforces.com/problemset/problem/294/B 题意: 有n本书,每本书的厚度为t[i],宽度为w[i] (1<=t[i]<=2, 1<=w[i]<=100). 然后让你将所有书按照下面的方式摆放: 在下面放一本书会占用下面t[i]的长度. 在上面放一本书会占用上面w[i]的长度. 最终要保证上面的总长度不超过下面的总长度. 问你下面的总长度最小是多少. 题解: 表示状态: dp[i][j] = min length 表示已经…
[题目链接]:click here~~ [题目大意]:一个robot 机器人 .能够依据给定的指令行动,给你四种指令,robot初始位置是(0,0).指令一出.robot会反复行动,推断是否能在无限行动的情况下经过点(n,m). [解题思路]事实上细致模拟一下,能够发现是有周期的.推断就可以,见代码吧~~ 代码: #include <iostream> #include <algorithm> #include <bits/stdc++.h> using namespa…
题目描述: B. Shaass and Bookshetime limit per test    2 secondsmemory limit per test 256 megabytesinput   standard inputoutput  standard output Shaass has n books. He wants to make a bookshelf for all his books. He wants the bookshelf's dimensions to be…
C. Vasya and Robot time limit per test: 1 secondmemory limit per test: 256 megabytesinput: standard inputoutput: standard output Vasya has got a robot which is situated on an infinite Cartesian plane, initially in the cell (0,0)(0,0)(0,0). Robot can…
题目 记忆化搜索(深搜+记录状态) 感谢JLGG //记忆话搜索 //一本书2中状态,竖着放或者横着放 //初始先都竖着放,然后从左边往右边扫 #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; ][][];//dp[第几个][厚度][宽度] int n; ],b[]; int rec(int i,int th,int w) { )return dp[i][th][w…
树形DP.由于n只有5000,可以直接枚举边. 枚举边,将树分成两个子树,然后从每个子树中选出一个点分别为u,v,那么答案就是: 子树1中任意两点距离总和+子树2中任意两点距离总和+子树1中任意一点到u的距离和*子树2的节点个数+子树2中任意一点到v的距离和*子树1的节点个数+子树1的节点个数*子树2的节点个数*当前枚举边的权值. 当枚举的边一定时,那么要选取的点就是子树中到所有点的距离总和最小的点.对树进行dfs,同时记录子树的节点个数,所有孩子节点到当前根节点的距离总和,以及当前子树中任意两…
这道题目的意思就是排两排书,下面这排只能竖着放,上面这排可以平着放,使得宽度最小 根据题意可以得出一个结论,放上这排书的Width 肯定会遵照从小到大的顺序放上去的 Because the total thickness of vertical books is fixed it's good to calculate the minimum possible total width of horizontal books. 那么只需要模拟一遍放书的过程即可,不会TLE 不过正统解法是Dp Dp…