![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
stl
努力写题的tyf
这个作者很懒,什么都没留下…
展开
-
士兵训练问题(list的使用)
某部队进行新兵队列训练,将新兵从一开始按顺序依次编号,并排成一行横队,训练的规则如下:从头开始一至二报数,凡报到二的出列,剩下的向小序号方向靠拢,再从头开始进行一至三报数,凡报到三的出列,剩下的向小序号方向靠拢,继续从头开始进行一至二报数。。。,以后从头开始轮流进行一至二报数、一至三报数直到剩下的人数不超过三人为止。 Input本题有多个测试数据组,第一行为组数N,接着为N行新兵人数,新兵人数不超...原创 2018-02-12 10:58:10 · 212 阅读 · 0 评论 -
2018年东北农业大学春季校赛 L - wyh的天鹅
链接:https://www.nowcoder.com/acm/contest/93/L来源:牛客网时间限制:C/C++ 3秒,其他语言6秒空间限制:C/C++ 262144K,其他语言524288K 64bit IO Format: %lld题目描述 你们wyh学长小时候住在河边,因为周围的生态环境非常好,所以经常会有天鹅浮在湖面上,每只天鹅都长得不一样,它们偶尔排成一排,偶尔分散开,偶尔也会...原创 2018-04-05 19:52:05 · 262 阅读 · 2 评论 -
nyoj1254 - Code the Tree
Code the Tree时间限制:1000 ms | 内存限制:65535 KB难度:3描述A tree (i.e. a connected graph without cycles) with vertices numbered by the integers 1, 2, ..., n is given. The "Prufer" code of such a tree is built ...原创 2018-05-19 21:31:25 · 379 阅读 · 1 评论 -
nyoj308 - substring
Substring时间限制:1000 ms | 内存限制:65535 KB难度:1描述You are given a string input. You are to find the longest substring of input such that the reversal of the substring is also a substring of input. In case ...原创 2018-05-25 17:55:35 · 138 阅读 · 0 评论 -
nyoj542 - 试 制 品 - set
试 制 品时间限制:1000 ms | 内存限制:65535 KB难度:4描述ZZ大学的Dr.Kong最近发现实验室的很多试制品都已经用完。由于项目经费有限,为了节省,Dr.Kong决定利用实验室现有的试制品来生成所缺的试制品。为此,Dr.Kong连续几天通宵达旦整理出一份研究资料并让研究生Bill去实验并统计能产生多少种所缺的试制品。Bill从头到尾翻完所有的资料,发现资料上写满了一大堆的化...原创 2018-05-23 11:24:10 · 134 阅读 · 0 评论 -
Hopscotch - poj3050 - dfs
HopscotchTime Limit: 1000MS Memory Limit: 65536K Total Submissions: 5435 Accepted: 3577 DescriptionThe cows play the child's game of hopscotch in a non-traditional way. Instead...原创 2018-07-30 21:15:57 · 247 阅读 · 0 评论 -
Protecting the Flowers - poj3262 - 贪心
Protecting the FlowersTime Limit: 2000MS Memory Limit: 65536K Total Submissions: 9384 Accepted: 3784 DescriptionFarmer John went to cut some wood and left N (2 ≤ N ≤ 100,000) c...原创 2018-08-09 22:02:24 · 175 阅读 · 0 评论 -
Expedition - poj2431 - 优先队列
ExpeditionTime Limit: 1000MS Memory Limit: 65536K Total Submissions: 22727 Accepted: 6443 DescriptionA group of cows grabbed a truck and ventured on an expedition deep into the...原创 2018-08-01 20:00:00 · 97 阅读 · 0 评论 -
Sunscreen - poj3614 - 贪心、优先队列
SunscreenTime Limit: 1000MS Memory Limit: 65536K Total Submissions: 10937 Accepted: 3835 DescriptionTo avoid unsightly burns while tanning, each of the C (1 ≤ C ≤ 2500) cows mu...原创 2018-08-02 19:43:34 · 148 阅读 · 0 评论 -
1016 Phone Bills - stl的使用
思路:参考柳神博客https://blog.csdn.net/liuchuo/article/details/52294397想了几个很复杂的方法都pass掉了,看了柳神博客,思路大概是,把所有的点都放到一个数组里,然后排序,按名字大小排,相同的按时间先后排,这样的话,我们判断的时候就比较数组的后一个元素和前一个元素,若名字同且后一个off-line前一个on-line那么就是成功匹配上了...原创 2018-10-22 21:46:37 · 262 阅读 · 0 评论 -
选拔赛总结
问题 B: 消灭复读机时间限制: 1 Sec内存限制: 512 MB提交: 18解决: 9[提交] [状态] [讨论版] [命题人:admin]题目描述手机端QQ推出了贴表情的新功能,复读机势力再次猖狂起来,她们把表情贴的到处都是!裙主决定把被复读次数最多的表情从聊天记录中删去。聊天框是一个大小为n x m的黑白点阵。背景色是白色。我们定义“表情”是由黑色色块组成的极大...原创 2019-03-03 10:54:49 · 481 阅读 · 0 评论 -
L3-002 特殊堆栈 - vector的妙用
堆栈是一种经典的后进先出的线性结构,相关的操作主要有“入栈”(在堆栈顶插入一个元素)和“出栈”(将栈顶元素返回并从堆栈中删除)。本题要求你实现另一个附加的操作:“取中值”——即返回所有堆栈中元素键值的中值。给定 N 个元素,如果 N 是偶数,则中值定义为第 N/2 小元;若是奇数,则为第 (N+1)/2 小元。输入格式:输入的第一行是正整数 N(≤105)。随后 N 行,每行给出一句...原创 2019-03-06 21:49:20 · 637 阅读 · 1 评论 -
L2-028 秀恩爱分得快
古人云:秀恩爱,分得快。互联网上每天都有大量人发布大量照片,我们通过分析这些照片,可以分析人与人之间的亲密度。如果一张照片上出现了 K 个人,这些人两两间的亲密度就被定义为 1/K。任意两个人如果同时出现在若干张照片里,他们之间的亲密度就是所有这些同框照片对应的亲密度之和。下面给定一批照片,请你分析一对给定的情侣,看看他们分别有没有亲密度更高的异性朋友?输入格式:输入在第一行给出 2 ...原创 2019-03-07 22:06:21 · 153 阅读 · 0 评论 -
stl merge函数使用
merge函数的作用是:将两个已经排好序的序列合并为一个有序的序列。函数参数:merge(first1,last1,first2,last2,result,compare);firs1t为第一个容器的首迭代器,last1为第一个容器的末迭代器;first2为第二个容器的首迭代器,last2为容器的末迭代器;result为存放结果的容器,comapre为比较函数(可略写,默认为合并为...原创 2019-05-03 10:59:18 · 1936 阅读 · 0 评论 -
hdu6287 - 口算训练 - stl、思维
思路:这个题看上去要T掉……但是我们可以对每个数分解质因子,(每个数都可以看成质因子的乘积)然后用vector存每个因子对应的下标,比如说6 4vec<2>: 1vec<3>: 1==========vec<2>: 2vec<2>: 2==========结果:vec<2>: 1 2...原创 2019-05-13 12:25:55 · 145 阅读 · 0 评论 -
第六章 - Matrix Chain Multiplication - uva442 - stack
Suppose you have to evaluate an expression like A*B*C*D*E where A,B,C,D and E are matrices.Since matrix multiplication is associative, the order in which multiplications are performed is arbitrary.How...原创 2018-04-07 21:03:09 · 274 阅读 · 0 评论 -
第六章 - Rails - uva514 - stack、模拟
There is a famous railway station in PopPush City. Country there is incredibly hilly. The stationwas built in last century. Unfortunately, funds were extremely limited that time. It was possible toest...原创 2018-04-07 21:23:53 · 162 阅读 · 0 评论 -
Let the Balloon Rise - map
Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges' favorite time is guessing the most popular problem. When the contest is over, they will co...原创 2018-02-11 23:49:09 · 138 阅读 · 0 评论 -
The kth great number - set
Xiao Ming and Xiao Bao are playing a simple Numbers game. In a round Xiao Ming can choose to write down a number, or ask Xiao Bao what the kth great number is. Because the number written by Xiao Ming ...原创 2018-02-11 22:56:53 · 247 阅读 · 0 评论 -
第五章 - uva - 540 - queue
Queues and Priority Queues are data structures which are known to most computer scientists. TheTeam Queue, however, is not so well known, though it occurs often in everyday life. At lunch time thequeu...原创 2018-02-11 22:37:06 · 163 阅读 · 0 评论 -
第五章 - Uva - 101 木块问题(详解) - vector
• move a onto b where a and b are block numbers, puts block a onto block b after returning any blocks that arestacked on top of blocks a and b to their initial positions.• move a over b where a and b ...原创 2018-02-11 22:24:36 · 743 阅读 · 3 评论 -
第五章 - STL 初步
STL-C++的标准模板库1.排序与检索sort(a,a+n)-排序lower-bound(a,a+n,x)在排序好的数组中查找大于或等于x的第一个位置#include<iostream>#include<cstdio>#include<algorithm>using namespace std;int a[6]={3,9,7,2,6,5};int...原创 2018-02-08 15:01:15 · 215 阅读 · 0 评论 -
全排序-next_permutation
Ray又对数字的列产生了兴趣: 现有四张卡片,用这四张卡片能排列出很多不同的4位数,要求按从小到大的顺序输出这些4位数。 Input每组数据占一行,代表四张卡片上的数字(0<=数字<=9),如果四张卡片都是0,则输入结束。 Output对每组卡片按从小到大的顺序输出所有能由这四张卡片组成的4位数,千位数字相同的在同一行,同一行中每个四位数间用空格分隔。 每组输出数据间空一行,最后一组数...原创 2018-02-14 17:17:12 · 220 阅读 · 0 评论 -
合并果子 - priority_queue
在一个果园里,多多已经将所有的果子打了下来,而且按果子的不同种类分成了不同的堆。多多决定把所有的果子合成一堆。每一次合并,多多可以把两堆果子合并到一起,消耗的体力等于两堆果子的重量之和。可以看出,所有的果子经过 n-1n−1次合并之后, 就只剩下一堆了。多多在合并果子时总共消耗的体力等于每次合并所耗体力之和。因为还要花大力气把这些果子搬回家,所以多多在合并果子时要尽可能地节省体力。假定每个果子重量...原创 2018-03-07 18:15:21 · 424 阅读 · 0 评论 -
第五章 - 代码对齐 - uva1593 - streamstring的用法
You are working in a team that writes Incredibly Customizable Programming Codewriter (ICPC) whichis basically a text editor with bells and whistles. You are working on a module that takes a piece ofco...原创 2018-03-15 20:49:14 · 233 阅读 · 1 评论 -
矩阵A乘以B - vector+矩阵乘法
题目描述给定两个矩阵A和B,要求你计算它们的乘积矩阵AB。需要注意的是,只有规模匹配的矩阵才可以相乘。即若A有Ra行、Ca列,B有Rb行、Cb列,则只有Ca与Rb相等时,两个矩阵才能相乘。输入输入先后给出两个矩阵A和B。对于每个矩阵,首先在一行中给出其行数R和列数C,随后R行,每行给出C个整数,以1个空格分隔,且行首尾没有多余的空格。输入保证两个矩阵的R和C都是正数,并且所有整数的绝对值不超过10...原创 2018-03-10 19:39:40 · 3108 阅读 · 0 评论 -
悄悄关注 - map
新浪微博上有个“悄悄关注”,一个用户悄悄关注的人,不出现在这个用户的关注列表上,但系统会推送其悄悄关注的人发表的微博给该用户。现在我们来做一回网络侦探,根据某人的关注列表和其对其他用户的点赞情况,扒出有可能被其悄悄关注的人。输入输入首先在第一行给出某用户的关注列表,格式如下:人数N 用户1 用户2 …… 用户N其中N是不超过5000的正整数,每个“用户i”(i=1, ..., N)是被其关注的用户...原创 2018-03-11 21:13:15 · 149 阅读 · 0 评论 -
第五章 - Ducci Sequence - uva1594 - vector,map
A Ducci sequence is a sequence of n-tuples of integers. Given an n-tuple of integers (a1, a2, · · · , an),the next n-tuple in the sequence is formed by taking the absolute differences of neighboring i...原创 2018-03-18 21:26:42 · 195 阅读 · 0 评论 -
第五章 - The SetStack Computer - uva - 12096
Background from Wikipedia: “Set theory is abranch of mathematics created principally by theGerman mathematician Georg Cantor at the end ofthe 19th century. Initially controversial, set theoryhas come ...原创 2018-03-12 21:05:45 · 174 阅读 · 0 评论 -
第五章 - Ugly Numbers - uva136 - priority_queue与set
Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, ...shows the first 11 ugly numbers. By convention, 1 is included.Write a program to fin...原创 2018-03-12 21:58:04 · 162 阅读 · 0 评论 -
L1-043. 阅览室 - PAT
天梯图书阅览室请你编写一个简单的图书借阅统计程序。当读者借书时,管理员输入书号并按下S键,程序开始计时;当读者还书时,管理员输入书号并按下E键,程序结束计时。书号为不超过1000的正整数。当管理员将0作为书号输入时,表示一天工作结束,你的程序应输出当天的读者借书次数和平均阅读时间。注意:由于线路偶尔会有故障,可能出现不完整的纪录,即只有S没有E,或者只有E没有S的纪录,系统应能自动忽略这种无效纪录...原创 2018-03-25 10:57:37 · 452 阅读 · 0 评论 -
Codeforces Round #585 (Div. 2) C - Swap Letters
比赛的时候wa了两发,赛后发现bug,改一发过了qwq思路:先统计a的总数和b的总数,若是出现奇数,输出-1接着统计,上下两行出现“ab”“ba”的次数,比如aabbbbbaba竖着看:ab出现了2次,ba出现了2次(1)ab出现了奇数次,那么ba一定也出现奇数次aaa baa...原创 2019-09-19 21:22:17 · 320 阅读 · 0 评论