Codeforces 861D - Polycarp's phone book】的更多相关文章

861D - Polycarp's phone book 思路:用map做的话,只能出现一次循环,否则会超时. 代码: #include<bits/stdc++.h> using namespace std; #define f first #define s second #define pb push_back #define mp make_pair map<string,int> ma; ]; int main(){ int n; string s,nu; cin>&…
<题目链接> 题目大意: 输入7e4个长度为9的字符串,每个字符串中只出现0~9这几种数字,现在需要你输出每个母串中最短的特有子串. 解题分析: 利用Trie树进行公共子串的判定,因为Trie树的特性是对节点的前缀字符串进行操作,所以为了转换成对母串中任意区间的字符串进行操作,我们对母串中的所有后缀字符串建树.下面用了一个比较优秀的Trie树模板. #include <cstdio> #include <cstring> #include <iostream>…
链接 Codeforces 659F Polycarp and Hay 题意 一个矩阵,减小一些数字的大小使得构成一个连通块的和恰好等于k,要求连通块中至少保持一个不变 思路 将数值从小到大排序,按顺序把与其相邻的加到并查集中.记录当前并查集中的个数,如果当前值能被K整除且总和超过了K,那么就可以以该点为中心输出了. 代码 #include <iostream> #include <cstdio> #include <vector> #include <stack…
C. Polycarp at the Radio time limit per test: 2 seconds memory limit per test: 256 megabytes input: standard input output: standard output Polycarp is a music editor at the radio station. He received a playlist for tomorrow, that can be represented a…
题目链接:http://codeforces.com/contest/727/problem/F 题目大意:有n个问题,每个问题有一个价值ai,一开始的心情值为q,每当读到一个问题时,心情值将会加上该问题的价值.问题只能按顺序读.有m个询问,求当q=bi时,至少要删去多少个问题才能使得在任何时候心情值都>=0 参考这篇:http://blog.csdn.net/aufeas/article/details/53031439 解法一: 贪心 分别求出最多删去i个问题需要的初始心情值的最小值f[i]…
Description Polycarp is a music editor at the radio station. He received a playlist for tomorrow, that can be represented as a sequence a1, a2, ..., an, where ai is a band, which performs the i-th song. Polycarp likes bands with the numbers from 1 to…
Description Polycarp loves lowercase letters and dislikes uppercase ones. Once he got a string s consisting only of lowercase and uppercase Latin letters. Let A be a set of positions in the string. Let's call it pretty if following conditions are met…
D. Polycarp's Picture Gallery time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Polycarp loves not only to take pictures, but also to show his photos to friends. On his personal website he h…
今天佛了,魔鬼周一,在线教学,有点小累,但还好,今天AC了一道,每日一道,还好达成目标,还以为今天完不成了,最近任务越来越多,如何高效完成该好好思考一下了~最重要的还是学业的复习和预习. 今日兴趣新闻: <流浪地球>中的逃生气囊球和马斯克有什么关系? 链接:https://mbd.baidu.com/newspage/data/landingsuper?context=%7B%22nid%22%3A%22news_8599496962815210358%22%7D&n_type=0&a…
有毒,自从上次选拔赛(哭哭)一个垃圾bfs写错之后,每次写bfs都要WA几发...好吧,其实也就这一次... 小白说的对,还是代码能力不足... 非常不足... 题目链接: http://codeforces.com/contest/659/problem/F 题意: n*m的格子,每个格子一个数,必须从格子中减去任意一个小于等于这个数的数. 给定数字k,要求: 剩下的格子数字和为k. 所有非零的格子的数字应该相同. 至少一个格子的数字没有改变. 含有非零数字的格子应该连通. 分析: 枚举每个能…