sgu 142. Keyword 暴力,hash 难度:0】的更多相关文章

142. Keyword time limit per test: 0.5 sec. memory limit per test: 16384 KB Kevin has invented a new algorithm to crypt and decrypt messages, which he thinks is unbeatable. The algorithm uses a very large key-string, out of which a keyword is found ou…
Description Harry Potter has some precious. For example, his invisible robe, his wand and his owl. When Hogwarts school is in holiday, Harry Potter has to go back to uncle Vernon's home. But he can't bring his precious with him. As you know, uncle Ve…
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1477 用IDA*可能更好,但是既然时间宽裕数据简单,而且记录状态很麻烦,就直接暴力了 #include <cstdio> #include <cstring> #include <algorithm> #include <cctype> using namespace std; char maz[54]; char readchar(){…
时间限制:0.5s 空间限制:16M 题意 给出一个仅由'a',‘b’组成的字符串S,长度小于500 000,求一个由‘a’,‘b’组成的不是S子串的字符串T. 输出T的长度和T. Sample Input 11 aabaaabbbab Sample Output 4 aaaa   Solution: 从字符串长度上看,我们需要一个O(n)的算法. 考虑串T的最大长度,在什么范围 长度为k的串,有2k个,占了k*2k位,即1*2+2*2k,+....+p*2P<=500 000; 可知串T的长度…
/********************************************************************************* * Refused to execute inline event handler because it violates the following Content Security Policy directive: "xxx". Either the 'unsafe-inline' keyword, a hash (…
NoReverseMatch at /salesman/zhuce/ Reverse for '/zhuce/' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: [] 对于上面的错误,有可能是django模板的错误,下面我粘贴出来错误的配置代码 一. 错误代码,错误部门用红色字体标出错误配置 <div id ="user"> <form action="…
Reverse for 'home' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: [] 此问题出现的原因是我的文件中出现了{{% url 'home' %}}这样的语句,url配置错误了,因为我并没有在相应的url配置语句里面指定name值. 解决方法只需要在相应的url配置后面加上name='home'就可以了 注:这种错误一般都是模板里面{% url '' %} 与urls.py中…
kruskal思想,排序后暴力枚举从任意边开始能够组成的最小生成树 #include <cstdio> #include <algorithm> using namespace std; const int maxn = 101; const int maxe = maxn * maxn / 2; struct edge{ int f,t,c; bool operator <(edge e2)const { return c<e2.c; } }e[maxe]; int…
Description Math Olympiad is called “Aoshu” in China. Aoshu is very popular in elementary schools. Nowadays, Aoshu is getting more and more difficult. Here is a classic Aoshu problem: ABBDE __ ABCCC = BDBDE In the equation above, a letter stands for…
125. Shtirlits time limit per test: 0.25 sec. memory limit per test: 4096 KB There is a checkered field of size N x N cells (1 Ј N Ј 3). Each cell designates the territory of a state (i.e. N2 states). Each state has an army. Let A [i, j] be the numbe…
111.Very simple problem time limit per test: 0.5 sec. memory limit per test: 4096 KB You are given natural number X. Find such maximum integer number that it square is not greater than X. Input Input file contains number X (1≤X≤101000). Output Write…
http://acm.fzu.edu.cn/problem.php?pid=2150 注意这道题可以任选两个点作为起点,但是时间仍足以穷举两个点的所有可能 #include <cstdio> #include <cstring> #include <queue> using namespace std; const int maxn=11; const int inf=0x3fffffff; char maz[maxn][maxn]; int dp[maxn][maxn…
Help Me with the Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3510   Accepted: 2251 Description Your task is to read a picture of a chessboard position and print it in the chess notation. Input The input consists of an ASCII-art…
Description Students often have problems taking up seats. When two students want the same seat, a quarrel will probably begin. It will have very bad effect when such subjects occur on the BBS. So, we urgently need a seat-taking-up rule. After several…
144. Meeting time limit per test: 0.25 sec. memory limit per test: 4096 KB Two of the three members of the winning team of one of the ACM regional contests are going to meet in order to train for the upcoming World Finals. They decided that they will…
139. Help Needed! time limit per test: 0.25 sec. memory limit per test: 4096 KB Little Johnny likes puzzles a lot! Just a few days ago, he found out about the 'traditional' 4x4 puzzle. For this puzzle, you have all the numbers from 0 to 15 arranged i…
112. a^b-b^a time limit per test: 0.25 sec. memory limit per test: 4096 KB You are given natural numbers a and b. Find a^b-b^a. Input Input contains numbers a and b (1≤a,b≤100). Output Write answer to output. Sample Input 2 3Sample Output -1 import j…
http://poj.org/problem?id=1050 设sum[i][j]为从(1,1)到(i,j)的矩形中所有数字之和 首先处理出sum[i][j],此时左上角为(x1,y1),右下角为(x2,y2)的矩形中所有数字之和就是sum[x2][y2]-sum[x1][y2]-sum[x2][y1]+sum[x1][y1] 因为n<100,在不需要优化的边上,所以就直接暴力了 #include <cstdio> #include <cstring> #include &l…
Borg Maze Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8905   Accepted: 2969 Description The Borg is an immensely powerful race of enhanced humanoids from the delta quadrant of the galaxy. The Borg collective is the term used to descr…
<传送门> 128. Snake time limit per test: 0.25 sec. memory limit per test: 4096 KB There are N points given by their coordinates on a plane. All coordinates (xi,yi) are integers in a range from -10000 up to 10000 inclusive . It is necessary to construct…
https://leetcode.com/problems/zigzag-conversion/ The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y…
https://leetcode.com/problems/bitwise-and-of-numbers-range/ [n,m]区间的合取总值就是n,m对齐后前面一段相同的数位的值 比如 5:101 7:111 结果就是 4:100 class Solution { public: int rangeBitwiseAnd(int m, int n) { int len = 0; long long tmp = 1; for(;tmp <= n || tmp <= m;len++){tmp&l…
https://leetcode.com/problems/add-two-numbers/ You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked…
https://leetcode.com/problems/two-sum/ class Solution { public: vector<int> twoSum(vector<int>& nums, int target) { vector<int> index(2,0); vector<int> n2; int numsSize = nums.size(); int f = -1; for(int i = 0;i < numsSize;i…
https://leetcode.com/problems/length-of-last-word/ int lengthOfLastWord(char* s) { int ans = 0; int fans = 0; for(int i = 0;s[i];i++){ if (s[i] ==' '){fans = ans;ans = 0;while(s[i + 1] == ' '){i++;}} else ans++; } return ans?ans:fans; }…
https://leetcode.com/problems/excel-sheet-column-number/ class Solution { public: int titleToNumber(string s) { int ans = 0; for(int i = 0;i < s.length();i++) { ans *= 26; ans += s[i] - 'A' + 1; } return ans; } };…
http://poj.org/problem?id=1094 #include <cstdio> #include <cstring> #include <vector> using namespace std; int in[27],out[27]; char index[27]; bool vis[27]; int mem[27][27]; int n,m; int tlen; bool floyd(){ for(int i=0;i<n;i++){ for(i…
http://poj.org/problem?id=2240 用log化乘法为加法找正圈 c++ 110ms,g++tle #include <string> #include <map> #include <iostream> #include <cmath> #include <cstring> #include <queue> using namespace std; const int maxn = 50; bool vis[…
http://poj.org/problem?id=1125 #include <iostream> #include <cstring> using namespace std; int d[101][101];// dag ATTENTION int num[101];//the number of contracts int edge[101][101];// adjecent edge table int n;//always represent the maxnum of…
http://poj.org/problem?id=2253 #include <iostream> #include <queue> #include <cmath> #include <iomanip> using namespace std; queue <int > que; int co[202][2]; double d[202][202],u[202][202]; int n; int main(){ ios::sync_with_…