[ABC262E] Red and Blue Graph】的更多相关文章

399B - Red and Blue Balls 思路: 惊讶的发现,所有的蓝球的消除都是独立的: 对于在栈中深度为i的蓝球消除需要2^i次操作: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; ; int main() { // freopen("ball.in","r…
题目链接:http://codeforces.com/problemset/problem/399/B 题目意思:给出 n 个只由 R 和 B 组成的字符串(由上到下排列,相当于栈),问最多可以操作多少轮.一轮包括三个步骤:(1)如果栈顶的球为 red,则弹出(注意可以弹出多个),直到遇到栈顶的球为blue  (2)将这个blue球替换为red球(只操作一次)  (3)在替换完red 球上面添加blue球,直到有 n 个球为止.当然一轮中不一定3个步骤都执行.当 n 个球都为red时,就不能再操…
#include <iostream> #include <string> using namespace std; int main(){ int n; cin >> n; string str; cin >> str; , x = ; ; i < n ; ++ i){ if(str[i] == 'B') cnt+=(x << i); } cout<<cnt<<endl; }   Codeforces Round…
思路:把字符串转化为一个二进制,遇到B就是一个数二进制中的1,答案就是这个数. #include <cstdio> #include <cstring> #include <algorithm> #define ll __int64 using namespace std; int n; ]; int main() { while(scanf("%d",&n)!=EOF) { scanf("%s",str); int k=…
n年没有更博客:我总结出了规律,当学的东西很难得时候都去学习,没有时间写博客,只有 内容对于我这种蒟蒻友好,又让我非常闲的慌时才写博客,这种博客以后也没有价值(也有些是做完一道题有成就感写的) 最近内容就不友好,离着一篇最近的博客还有10几天,那个也是因为有成就感.... 这个是之前写好的,搬到这里来只是不会觉得太长时间没有更博客 这个题一开始我把左右搞反了 结果考试0分 反过来就对了.... 分割线 如果一个栈中最低端已经是红球就相当于不用处理栈底 假设一个栈中只有蓝球,会是多少步呢? 由打表…
题目 CF399B 洛谷RemoteJudge 思路 很容易发现,栈中靠上的蓝色球的出栈,对它下方的蓝色球没有影响. 举个例子: 第一步中靠上的蓝色球在第三步出栈了,这一过程对它下面的蓝色球(即第一步中靠下的蓝色球)没有产生影响. 这启示我们由上到下分别计算每一颗(初始状态下的)蓝色球出栈需要的步数,再相加得到答案. 不妨设\(f(x)\)表示离栈顶距离为\(x\)的蓝色球出栈需要的步数,那么上面的样例的答案即为\(f(2)+f(3)\),即"离栈顶距离为\(2\)的蓝色球出栈所需步数\(+\)…
Given an undirected graph, return true if and only if it is bipartite. Recall that a graph is bipartite if we can split it's set of nodes into two independent subsets A and B such that every edge in the graph has one node in A and another node in B.…
Given an undirected graph, return true if and only if it is bipartite. Recall that a graph is bipartite if we can split it's set of nodes into two independent subsets A and B such that every edge in the graph has one node in A and another node in B.…
转帖:http://www.glenstevens.ca/unity3d-best-practices/ 另外可以参考:http://devmag.org.za/2012/07/12/50-tips-for-working-with-unity-best-practices/ 组件的拆分可以参考:http://gameprogrammingpatterns.com/component.html,此网站上列出了很多的游戏开发中的设计模式,非常值得认真研读. 论坛里的讨论也很有价值:https://…
    Graph-powered Machine Learning at Google     Thursday, October 06, 2016 Posted by Sujith Ravi, Staff Research Scientist, Google ResearchRecently, there have been significant advances in Machine Learning that enable computer systems to solve compl…