Problem D: Queens, Knights and PawnsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=88443#problem/D Description You all are familiar with the famous 8-queens problem which asks you to place 8 queens…
Description You all are familiar with the famous 8-queens problem which asks you to place 8 queens on a chess board so no two attack each other. In this problem, you will be given locations of queens and knights and pawns and asked to find how many o…
There is No Alternative 题目连接: http://codeforces.com/gym/100803/attachments Description ICPC (Isles of Coral Park City) consist of several beautiful islands. The citizens requested construction of bridges between islands to resolve inconveniences of u…
原题地址:http://codeforces.com/gym/100286/attachments/download/2013/20082009-acmicpc-northeastern-european-regional-contest-neerc-08-en.pdf 此题题意是给你一个单对单密文,让你还原为原文,原文有个性质是,每个单词都是元音和辅音交替组成. 做法是直接5重for,暴力枚举AEIOU分别对应的字母,然后检查,然后输出 详见代码: //#include<iostream>…
Problem C. Painting CottagesTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/attachments Description The new cottage settlement is organized near the capital of Flatland. The construction company that is building the sett…
I. Sale in GameStore Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513/problem/I Description A well-known Berland online games store has announced a great sale! Buy any game today, and you can download more games for free!…
G - Good elementsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87954#problem/G Description You are given a sequence A consisting of N integers. We will call the i-th element good if it equals the s…
题目传送门 传送门 题目大意 $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$只鼹鼠醒来,最小的移动距离的总和. 考虑费用流的建图和暴力做法,把原图的…
一句话题意:x0=1,xi+1=(Axi+xi%B)%C,如果x序列中存在最早的两个相同的元素,输出第二次出现的位置,若在2e7内无解则输出-1. 题解:都不到100天就AFO了才来学这floyd判圈算法. 介绍一下floyd判圈算法:该算法适用于在线性时间复杂度内判断有限自动机.迭代函数.链表中是否有环,求环的起点(即链长)和环长. 可以先这么做:首先从起点S出发,给定两个指针,一个快指针一个慢指针,然后每次快指针走1步,慢指针走2步,直到相遇为止.如果已经到达终点/达到规定步数时仍然没有相遇…
题目传送门 传送门 题目大意 给定一个长度为$n$的序列,要求划分成最少的段数,然后将这些段排序使得新序列单调不减. 考虑将相邻的相等的数缩成一个数. 假设没有分成了$n$段,考虑最少能够减少多少划分. 我们将这个序列排序,对于权值相同的一段数可以任意交换它们,每两个相邻数在原序列的位置中如果是$i, i + 1$,那么划分的段数就可以减少1. 每次转移我们考虑添加值相同的一段. 每次转移能不能将减少的段数加一取决于当前考虑的数在前一段内有没有出现以及有没有作为最左端点. 因此我们记录一个决策与…