题意:给一个元素周期表的元素符号(114种),再给一个串,问这个串能否有这些元素符号组成(全为小写). 解法1:动态规划 定义:dp[i]表示到 i 这个字符为止,能否有元素周期表里的符号构成. 则有转移方程:dp[i] = (dp[i-1]&&f(i-1,1)) || (dp[i-2]&&f(i-2,2))     f(i,k):表示从i开始填入k个字符,这k个字符在不在元素周期表中.  dp[0] = 1 代码: //109ms 0KB #include <ios…
#include<iostream> #include<string.h> #include<stdio.h> #include<ctype.h> #include<algorithm> #include<stack> #include<queue> #include<set> #include<math.h> #include<vector> #include<map> #…
题意:给你n个点(n<=50),然后有些点之间会有一条路,路是单向的,每个回合让你走a,b,c三种步数中的任意一种(a,b,c<=100),问你最少需要多少个回合才能保证一定能从1点到达n点: #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <iostream> #include <cmath> #…
这道题在LA是挂掉了,不过还好,zoj上也有这道题. 题意:好大一颗树,询问父子关系..考虑最坏的情况,30w层,2000w个点,询问100w次,貌似连dfs一遍都会TLE. 安心啦,这肯定是一道正常人能做的题目.不过是需要几个小技巧. 1.2000w个点不一定都要保存下来,事实上,虽然题目给了256M的空间,只要开了两个这么大的数组,MLE是跑不了的,所以只保存30w个父节点. 2.如果这30w个父节点构成一条链,dfs的栈肯定爆.所以需要用栈模拟dfs.这里用的是stack<int>,当然…
题目链接:https://cn.vjudge.net/contest/209473#problem/D 题目大意:有一棵树,这棵树的前n个节点拥有子节点,告诉你n的大小,以及这n个节点各有的子节点个数,对于Q个询问<x,y>,回答x是否是y的祖先. 解题思路: 一开始想的LCA,倍增解决.然后一看数据范围,2e7!瞬间被吓回来了. 想了各种方法百思不得其解最后看了题解orz(强烈建议独立思考,挫败感很强!). 题解……万分机智,我们思考一下深搜建树的过程,先遍历到一个父亲节点,再往下遍历到这个…
服务器文档下载zip格式   刚好这次项目中遇到了这个东西,就来弄一下,挺简单的,但是前台调用的时候弄错了,浪费了大半天的时间,本人也是菜鸟一枚.开始吧.(MVC的) @using Rattan.Core.Utility;@{ string ButtonScript = string.Empty;}@if (Rattan.Basic.Globals.GetIsAuth(ViewBag.AuthValues, "QuickExport")){ ButtonScript = @"…
题目链接 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4268 题意 给出化学元素周期表,然后给出一个字符串,判断字符串里面的字符,能不能够完全由元素周期表里面的元素构成 或者换一种说法,将字符串切割成若干个子串,能不能有一种切割的方式,使得切割下来的每一个子串都是元素周期表里面的元素 思路 其实可以发现 元素周期表里面的…
字符串处理的题目: 学习了一下string类的一些用法: 这个代码花的时间很长,其实可以更加优化: 代码: #include<iostream> #include<string> using namespace std; ]= {"he","h","li","be","b","c","n","o","f"…
Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, n] inclusive that do not appear in this array. Could you do it without extra space and in O(n) runtime?…
Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to find the number of connected components in an undirected graph. Example 1: 0          3 |          | 1 --- 2    4 Given n = 5 and…