题目链接:http://codeforces.com/gym/100971/problem/K K. Palindromization time limit per test 2.0 s memory limit per test 256 MB input standard input output standard output Mihahim has a string s. He wants to delete exactly one character from it so that th…
A题  直接把问号全部变为陆地如果所有陆地连通    那么再逐个把刚才变成陆地的问号变为水如果依旧连通有多种解 为什么我的代码跑不过去,和网上的题解思路一模一样!!?? #include<cstdio> #include<algorithm> #include<cstring> #include<iostream> #define MAX_N 55 using namespace std; char map[MAX_N][MAX_N]; int n,m; i…
K. Perpetuum Mobile Time Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/problem/K Description The world famous scientist Innokentiy almost finished the creation of perpetuum mobile. Its main part is the energy generator which…
D. Laying Cables time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output One-dimensional country has n cities, the i-th of which is located at the point xi and has population pi, and all xi, as we…
K - Cross SpiderTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87794#problem/K Description The Bytean cross spider (Araneida baitoida) is known to have an amazing ability. Namely, it can instantly b…
题意:给你两个字符串a,b,不区分大小写,将b分成三段,重新拼接,问是否能得到A: 思路:暴力枚举两个断点,然后check的时候需要字符串hash,O(1)复杂度N*N: 题目链接:传送门 #pragma comment(linker, "/STACK:1024000000,1024000000") #include<iostream> #include<cstdio> #include<cmath> #include<string> #…
题目大意 将一个含有+,-,^,()的表达式按照运算顺序转换成树状的形式. 解题分析 用递归的方式来处理表达式,首先直接去掉两边的括号(如果不止一对全部去光),然后找出不在括号内且优先级最低的符号.如果优先级相同,则如果是左结合性(+,-,*,/)则选择最右边的一个,如果是右结合性(^)则选择最最左边的一个. 主要恶心的地方在于输出上.主要是记录一下每个点和符号的位置,在递归和返回时传递一些参数. ps:虽然输出比较恶心,但最终实现出来后还是感到十分地身心愉悦. 参考程序 #include <b…
题目链接 题意 : 给出 N 个点(最多 1e6 )和 M 条边 (最多 N + 20 条 )要你输出一条从 1 开始回到 1 的哈密顿回路路径,不存在则输出 " There is no route, Karl! " 分析 :  题意很简单明了 众所周知,哈密顿回路是个 NP-Hard 问题 这么多个点的哈密顿回路肯定是不能暴力去寻找的 但是关注到 M ≤ N + 20 这个特殊的条件 那就说明图中肯定有很多单向链 那么这题就很明确了,就把所有的单链缩成一个点 然后再去 DFS 暴力找…
Codeforces Gym 100725K 题意:给定一个初始全0的序列,然后给\(n\)个查询,每一次调用\(Insert(L_i,i)\),其中\(Insert(L,K)\)表示在第L位插入K,如果第L位已经有值了就会先调用\(Insert(L+1,A_L)\)(其中\(A_L\)表示第L位上的值),再将\(A_L\)赋为K.问经过查询后序列的模样. 思路:首先将题意抽象成每次找到从第L位开始第一个0,并将其"拖"回第L位,然后将其更改为K.这个操作很明显可以用FHQ Treap…
题目传送门 传送门 题目大意 $m$只鼹鼠有$n$个巢穴,$n - 1$条长度为$1$的通道将它们连通且第$i(i > 1)$个巢穴与第$\left\lfloor \frac{i}{2}\right\rfloor$个巢穴连通.第$i$个巢穴在最终时允许$c_i$只醒来的鼹鼠最终停留在这.已知第$i$只鼹鼠在第$p_i$个巢穴睡觉.要求求出对于每个满足$1 \leqslant k \leqslant n$的$k$,如果前$k$只鼹鼠醒来,最小的移动距离的总和. 考虑费用流的建图和暴力做法,把原图的…