- 博客(41)
- 收藏
- 关注
原创 leetcode28 实现strStr()
就是一个普通的KMP,这里推荐一篇文章,我觉得写得非常好,没事可以经常翻出来看看https://blog.youkuaiyun.com/gao506440410/article/details/81812163class Solution {public: int strStr(string haystack, string needle) { if(needle.l...
2019-07-18 23:56:50
192
原创 leetcode26 删除排序数组中的重复项
昨天那两个太简单了,不写了,注意复习一下链表的操作就好了。今天这个也不应该写的,有点zz考虑到要返回结果,第一反应是用迭代器遍历class Solution {public: int removeDuplicates(vector<int>& nums) { if(nums.size() == 0) return 0; ...
2019-07-18 15:45:26
212
原创 leetcode14 最长公共前缀
先说点废话。。距离上一次写博客已经4年了,不碰ACM也有两年多了,迫于要找工作的压力吧,外加记性实在是不好,决定以后每天写一道题,争取每道题都写博客,闲的时候翻一翻先从简单题开始写吧。。。编写一个函数来查找字符串数组中的最长公共前缀。如果不存在公共前缀,返回空字符串""。示例1:输入: ["flower","flow","flight"]输出: "fl"示例2:...
2019-07-17 00:21:14
246
原创 POJ 3279.Fliptile
二维翻转问题,比较复杂,琢磨了好久。这个问题比一维的要麻烦好多,一维裸暴力就能过去。目测这题的数据量裸暴力也能过,但是我还是作死的选择了搜索。。。搜索上没有难度,需要注意的问题是对翻转点的标记以及状态转移(是这么叫的吗?。。。)这一周以来最大的工程,代码摆上,欢迎hackPS:诸如“这种破代码居然还要写这么久哼哼简直就是渣渣。。。”的话就不要说了,我
2015-12-12 17:21:57
487
原创 Codeforces 335A.Magic Spheres
(这种题居然要写解题报告我也是醉了,说好了要做点高难度的呢?!)这题当时半夜没想明白,第二天在栗神的帮助理解下琢磨出来了。一句话,作差大于0除以2小于零就不管最后求和看看是不是大于0就好了。。。#include #include #include using namespace std;int main(){ int a, b, c, x, y, z
2015-12-12 08:55:04
469
原创 POJ 3278.Catch That Cow
简单BFS,之前碰见过,但是因为当时太弱了没搞出来。。。(虽然现在也很弱 - -)使用了quene,然而脑残忘了清空队列,wa了好几发#include #include #include #include #include using namespace std;queue p;bool vis[100010];int ans[100010];int bfs
2015-12-12 08:48:29
362
原创 POJ 2251.Dungeon Master(BFS)
题目传送门三维搜索,多了一维也就是多了上下两个方向,调整好姿势就可以了。最开始在队列的处理上不太恰当TLE了几发(也可能是POJ的评测机炸了),后来调整了一下过掉了,注意输入字符时getchar#include #include #include #include using namespace std;struct p{ int a, b, c;}
2015-12-10 00:04:04
404
原创 HDU 4597.Play Game(DP)
题目传送门写这个博客证明我做过这道题。。。l和r分别表示牌堆里第一张牌和最后一张牌然后针对每种取牌方式对bob上一次取牌之后的可能情况取最大值#include#include#include#includeusing namespace std;int a[25], b[25];int dp[25][25][25][25];int
2015-10-05 21:41:43
437
原创 POJ 3461.Oulipo(KMP)
题目传送门KMP模板题,不多说。就是string的操作没有得到正确结果,肾略疼。。。#include#include#include#include#includeusing namespace std;int next[10000010];//string T,W;char T[1000010], W[1000010];voi
2015-09-18 22:43:11
443
原创 UVA 11292 - Dragon of Loowater
题目传送门红果果的贪心,外加一点点的优化,大约能快个0.01s....好像并没有什么卵用#include #include #include using namespace std;int a[20010], b[20010];int n, m;int main(){ #ifdef sxy freopen("in.txt
2015-09-06 15:02:07
392
原创 HDU 1051.Wooden Sticks
Wooden SticksTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 15109 Accepted Submission(s): 6198Problem DescriptionThere is a pile
2015-08-26 20:06:58
424
原创 HDU 1009.FatMouse' Trade
FatMouse' TradeTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 54467 Accepted Submission(s): 18265Problem DescriptionFatMouse pre
2015-08-24 20:46:09
417
原创 URAL 1581.Teamwork
1581. TeamworkTime limit: 1.0 secondMemory limit: 64 MBVasya and Petya are going to participate in a team olympiad in informatics. They have listened to the stories told by the gurus of olympi
2015-08-24 20:44:58
452
原创 POJ 1423.Big Number
Big NumberTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 26943 Accepted: 8608DescriptionIn many applications very large integers numbers are required. So
2015-08-22 16:52:24
162
原创 POJ 1321.棋盘问题
棋盘问题Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 28752 Accepted: 14234Description在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对
2015-08-22 15:37:47
405
原创 POJ 3069.Saruman's Army(贪心)
Saruman's ArmyTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 5580 Accepted: 2857DescriptionSaruman the White must lead his army along a straight path f
2015-08-17 17:26:37
423
原创 POJ 3617.Best Cow Line
Best Cow LineTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 13735 Accepted: 3934DescriptionFJ is about to take his N (1 ≤ N ≤ 2,000) cows to the annu
2015-08-17 14:19:33
390
原创 BestCoder Round #50 (div.2) 1001
Distribution moneyAccepts: 713Submissions: 1881Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Problem DescriptionAFA want to distribution her
2015-08-09 09:26:41
388
原创 URAL 1319. Hotel
1319. HotelTime limit: 1.0 secondMemory limit: 64 MB— You programmers are lucky! You don't have to deal with these terrible people – designers… This story happened with me not so long ago.
2015-08-08 17:39:05
591
原创 2015暑假训练题解(二分)
A题 (poj2503)这道题很容易就想到枚举,然而枚举会浪费时间。。。所以说这道题先排序,然后再二分,运行速度嗖嗖嗖~#include#include#include#includeusing namespace std;const int mm=100010;struct node{ char e[60],s[60];}dic[mm];char t[6
2015-07-13 16:53:13
606
原创 Codeforces 448 D. Multiplication Table
D. Multiplication Tabletime limit per test 1 secondmemory limit per test 256 megabytesinput standard inputoutput standard outputBizon the Champion isn't just ch
2015-04-30 12:09:06
157
原创 HDOJ 1233.还是畅通工程
还是畅通工程Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 28959 Accepted Submission(s): 12951Problem Description某省调查乡村交通状况,得到的统计表中列出了任意
2015-04-01 22:54:06
573
原创 HDOJ 1272.小希的迷宫
小希的迷宫Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 30146 Accepted Submission(s): 9354Problem Description上次Gardon的迷宫城堡小希玩了很久(见Prob
2015-04-01 18:26:02
609
原创 HDOJ 1232.畅通工程
畅通工程Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 34007 Accepted Submission(s): 17970Problem Description某省调查城镇交通状况,得到现有城镇道路统计表,表中
2015-03-31 19:54:12
669
原创 HDOJ 1213.How Many Tables
How Many TablesTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 16221 Accepted Submission(s): 7955Problem DescriptionToday is Ignati
2015-03-29 21:36:02
426
原创 Codeforce 1A. Theatre Square
A. Theatre Squaretime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard outputTheatre Square in the capital city of Berl
2015-03-24 22:14:01
563
原创 URAL 1639. Chocolate 2
1639. Chocolate 2Time limit: 1.0 secondMemory limit: 64 MBLittle Boy is mad at Karlsson, who ate all the sweets in the flat and even went to the neighbours to eat their sweets too. Now L
2015-03-24 20:14:36
804
原创 URAL 2012. About Grisha N.
2012. About Grisha N.Time limit: 1.0 secondMemory limit: 64 MBGrisha N. told his two teammates that he was going to solve all given problems at the subregional contest, even if the teamm
2015-03-24 19:31:31
721
原创 URAL 1910. Titan Ruins: Hidden Entrance
1910. Titan Ruins: Hidden EntranceTime limit: 1.0 secondMemory limit: 64 MBSoren and Alba were famous and powerful wizards. They had been the founders of a magic guild that had united wi
2015-03-24 17:37:39
325
原创 URAL 1197. Lonesome Knight
1197. Lonesome KnightTime limit: 1.0 secondMemory limit: 64 MBThe statement of this problem is very simple: you are to determine how many squares of the chessboard can be attacked by a k
2015-03-21 18:38:59
710
原创 URAL 2001. Mathematicians and Berries
2001. Mathematicians and BerriesTime limit: 0.5 secondMemory limit: 64 MBOne day, two mathematicians were walking in the forest and picking berries. They’d been walking for two hours, an
2015-03-20 19:27:08
539
原创 URAL 1880. Psych Up's Eigenvalues
1880. Psych Up's EigenvaluesTime limit: 0.5 secondMemory limit: 64 MBAt one of the contests at the Petrozavodsk Training Camp, players of the Psych Up team quickly found the simple probl
2015-03-19 22:36:50
492
原创 URAL 1264. Workdays
1264. WorkdaysTime limit: 1.0 secondMemory limit: 64 MBAfter a success of the previous Vasechkin’s program that allowed to calculate the results of the elections in cause of two days Art
2015-03-18 22:37:15
459
原创 URAL 1787. Turn for MEGA
1787. Turn for MEGATime limit: 1.0 secondMemory limit: 64 MBA traffic light at the turn for the “MEGA” shopping center from the Novomoskovskiy highway works in such a way that k cars are
2015-03-14 18:41:18
771
原创 URAL 1820. Ural Steaks
1820. Ural SteaksTime limit: 0.5 secondMemory limit: 64 MBAfter the personal contest, happy but hungry programmers dropped into the restaurant “Ural Steaks” and ordered n specialty steak
2015-03-13 21:30:56
590
原创 URAL 1409. Two Gangsters
1409. Two GangstersTime limit: 1.0 secondMemory limit: 64 MBTwo gangsters Harry and Larry had a rest at countryside. They decided to spend some time shooting, so they put several beer ca
2015-03-10 18:50:37
618
原创 URAL 1877. Bicycle Codes
1877. Bicycle CodesTime limit: 0.5 secondMemory limit: 64 MBDen has two four-digit combination locks for protecting his bicycle from thieves. Every evening he arms the bicycle antitheft
2015-03-10 18:24:49
549
原创 URAL 1293. Eniya
1293. EniyaTime limit: 1.0 secondMemory limit: 64 MBIt’s restless now on the slips of the intergalactic port’s sixth dock of planet of Torn. No longer then in a month the reconstruction
2015-03-10 18:10:49
642
原创 URAL 1001. Reverse Root
好久时间没做题了,捅咕了半天才水出这么了一道题...1001. Reverse RootTime limit: 2.0 secondMemory limit: 64 MBThe problem is so easy, that the authors were lazy to write a statement for it!InputThe
2015-03-09 21:11:02
497
转载 C++string类常用函数
string类的构造函数:string(const char *s); //用c字符串s初始化string(int n,char c); //用n个字符c初始化此外,string类还支持默认构造函数和复制构造函数,如string s1;string s2="hello";都是正确的写法。当构造的string太长而无法表达时会抛出length_error异常stri
2015-01-15 21:09:29
643
1
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅