题目链接:http://codeforces.com/contest/673/problem/C 题意:给一串数,不同大小的区间内出现次数最多的那个数在计数的时候会+1,问所有区间都这样计一次数,所有的数字的计数结果.如果有数字出现次数相同多,取最小的那个. 数据<=5000,那就暴力枚举每一个区间,每次维护当前出现最多次数和当前需要计数的那个数,每次更新一个值,那最大值就是这个值或者是之前存好的.每次判断就可以了,注意相同的时候取最小的那个数. /* ━━━━━┒ギリギリ♂ eye! ┓┏┓┏…
C. Bear and Colors time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Bear Limak has n colored balls, arranged in one long row. Balls are numbered 1 through n, from left to right. There are n…
C. Bear and Colors 题目连接: http://www.codeforces.com/contest/673/problem/C Description Bear Limak has n colored balls, arranged in one long row. Balls are numbered 1 through n, from left to right. There are n possible colors, also numbered 1 through n.…
题目链接: C. Bear and Colors time limit per test 2 seconds   memory limit per test 256 megabytes input standard input output standard output Bear Limak has n colored balls, arranged in one long row. Balls are numbered 1 through n, from left to right. The…
C. Bear and Colors time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Bear Limak has n colored balls, arranged in one long row. Balls are numbered 1 through n, from left to right. There are n…
Lara Croft, the fiercely independent daughter of a missing adventurer, must push herself beyond her limits when she discovers the island where her father disappeared. In this mysterious island, Lara finds a tomb with a very heavy door. To open the do…
上次周赛碰到这个题目,居然都没思路,真是不应该啊,起码也应该想到枚举法. 因为题目只允许每一row进行reverse操作,而每两列可以进行交换操作,所以首先把row的变化固定下来,即枚举第一列与第1-m列进行交换,之后逐个检查每一行第一列的状态 与 终态是否一致,不一致的话则该行就一定要进行reverse操作了,这样下来,每次枚举就把row的reverse变化给固定下来,接下来只要枚举 接下来的2-m行互相的列变换即可,只需一个嵌套循环即可,总的循环也只是三重 而n和m仅有100,规模承担的起…
A. Bear and Big Brother time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Bear Limak wants to become the largest of bears, or at least to become larger than his brother Bob. Right now, Limak…
http://codeforces.com/problemset/problem/673/C 先说一个枚举区间的技巧,枚举前缀,不要枚举后缀. 就是下面这个代码是不好的 ; i <= n; ++i) { ; j <= i; ++j) { 区间[j, i] } } 为什么呢?就是很多东西重复了,而且也被迫用不上.只能老老实实地计算. 但如果考虑下枚举前缀. ; i <= n; ++i) { for (int j = i; j <= n; ++j) { 区间[i, j] } } 则能用…
Fliptile Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 14297   Accepted: 5257 Description Farmer John knows that an intellectually satisfied cow is a happy cow who will give more milk. He has arranged a brainy activity for cows in whic…
题目链接: http://codeforces.com/contest/673/problem/C 题解: 枚举所有的区间,维护一下每种颜色出现的次数,记录一下出现最多且最小的就可以了. 暴力n*n. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<vector> using namespace std; ; const int…
#点击传送 题目描述 Recently Vasya found a golden ticket - a sequence which consists of nn digits a1a2-ana1a2-an. Vasya considers a ticket to be lucky if it can be divided into two or more non-intersecting segments with equal sums. For example, ticket 3501783…
传送门 Description 给你一个0/1矩阵,可以将矩阵中的0变成1,问最少经过多少此操作使得矩阵任意一元素四周的元素和为偶数. Input 第一行是一个整数T代表数据组数,每组数据包含以下内容: 第一行是一个整数n,代表矩阵的行列数 接下来n行每行n个用空格隔开的整数,代表矩阵元素. Output 对于每组数据输出一行,格式为Case X: ans Sample Input Sample Output Case : Case : Case : - Hint 1≤n≤15,数据不超过30组…
You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ii-th lamp is sisi ('R', 'G' and 'B' - colors of lamps in the garland). You have to recolor some lamps in this garland (recoloring a lamp means chang…
状压以后,直接暴力枚举,2^20约等于1e6,而且满足bitcount = m的状态很少. #include<bits/stdc++.h> using namespace std; +; double x[maxn],y[maxn],z[maxn]; double d[maxn][maxn]; double squ(double x) { return x*x; } double dist(int i,int j) { return squ(x[i]-x[j])+squ(y[i]-y[j])+…
题目链接: http://codeforces.com/problemset/problem/653/C 题意: 给定序列,偶数位的数字比两边都大,则成为nice,只可以交换两个数字,问有多少种交换方式使得最后的序列为nice. 分析: 比赛的时候找规律,找呀找了好久都没看出来....由于只可以交换一次,交换两个数字,所以最多改变的6个数字的关系.那么可以交换成nice的话,原来不满足的肯定很少,直接把这些数字提出来,然后暴力的和序列每个元素交换一下,看看其余不满足的是否变成满足就好啦~~~ 代…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] O(n^2)枚举每一个区间. 然后维护这个区间里面的"统治数字"是什么. 对于每个区间cnt[统治数字]++; [代码] #include <bits/stdc++.h> using namespace std; const int N = 5000+10; int n; int t[5000+10]; int num[5000+10],cnt[N]; int main() { ios::sync_with…
题目描述 Farmer John has bought property in the Caribbean and is going to try to raise dairy cows on a big farm composed of islands. Set in his ways, he wants to surround all the islands with fence. Each island in the farm has the shape of a polygon. He…
这个题其实由于只有4种花色的,那么每种花色排列的顺序,也不过是4!种,然后对于每种花色内部到底是升序还是降序,其实也可以直接暴力,一共也就4!*2^4种情况,然后直接进行排序就可以了,但是我们如何计算需要移动的位置呢???我们这样考虑,我们由于要保证内部有序,那么最后一定是一个升序或者降序,那么插入一张牌,实际上是相当改变内部相对位置,那么考虑无序的,我们肯定是找到最长的递增子序列,那么他们一定是不用互相移动的,而其他的肯定是要移动的,因为他们不满足前后的顺序,并且他们是肯定是要移动的,直接二进…
题意 题解 可以发现当a=10001时, 和1是等价的. 所以这题就水了. #include<iostream> #include<cstring> #include<cstdio> #include<cmath> #include<algorithm> using namespace std; ; long long ksm(long long x,long long b){ ; while(b){ ){ tmp=(tmp*x)%mod; }…
Description Natasha is planning an expedition to Mars for nn people. One of the important tasks is to provide food for each participant. The warehouse has m daily food packages. Each package has some food type aiai. Each participant must eat exactly…
POJ 2182 暴力 /* 题意: 一个带有权值[1,n]的序列,给出每个数的前面比该数小的数的个数,当然比一个数前面比第一个数小的个数是0,省略不写,求真正的序列.(拗口) 首先想到的是从前到后暴力枚举暴力枚举.数据量为8000,O(n^2). */ #include<cstdio> #include<iostream> #include<cstring> #include<cstdlib> #include<algorithm> #incl…
暴力破解 By : Mirror王宇阳 笔者告知 : 暴力破解的结果是运气和速度的结晶,开始暴力破解前烧一炷香也是必要的! 引用张炳帅的一句话:"你的运气和管理员的安全意识成正比" Hydra Hydra是一款开源的暴力破解工具,支持FTP.MSSQL.MySQL.PoP3.SSH等暴力破解 引入<web安全深度剖析> 参数选项 参数 说明 -R 继续上一次的进度开始破解 -S 使用 SSL 链接 -s [port] 使用指定端口port -I [login] 使用指定的登…
C. Bear and Colors time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Bear Limak has n colored balls, arranged in one long row. Balls are numbered 1 through n, from left to right. There are n…
A题 子序列和啊,就要想到前缀和的差.这个转换一定要!记着!那么i到j的一段子序列和Sij%m ==  0就等价于(Sj-Si-1)%m == 0 了,那么什么意思呢?就是如果有两段前缀和%m的模是一样的,那么是不是就存在着一段子序列满足条件了,然后注意一下边边角角应该就没问题了.因为ZOJ坏掉了,所以我尚未验证以下答案的ans是否就是满足条件的序列总数!移步ZOJ1569自行验证. #include <cstdio> #include <set> #include <map…
题意:建一个家庭树,找出有第d代子孙的名字,按照要求的第d代子孙的数从大到小输出三个人名,如果有一样大小子孙数的,就按字母序从小到大将同等大小的都输出,如果小于三个人的就全输出. 题目链接:http://poj.org/problem?id=2732 分析:数据量很小,直接建树,枚举暴力输出.我直接套模板用map建树的. 注意:1.每次测试数据时要清空map和vector!!! 2.注意输出要从大到小输出答案,如果答案有一样的按名字的字母序从小到大输出.答案用vector保存,vector排序:…
Problem Statement      Masterbrain is a two player board game in which one player decides on a secret combination of digits, while the other must figure it out in 10 guesses or less. The game differs from Mastermind in that the player making the secr…
枚举/暴力/Kruskal orz……我sb了……其实是sb题<_< 有一道题问的是最小极差生成树……(不记得是什么名字了,就是求最大边权与最小边权差最小的生成树)做法是枚举最小边,然后kruskal找最大边 这题同理,因为$m\leq 5000$,所以$m^2$的算法即可…… /************************************************************** Problem: 1050 User: Tunix Language: C++ Resul…
Problem 2178 礼物分配 题目链接: Click Here~ Problem Description 在双胞胎兄弟Eric与R.W的生日会上,他们共收到了N个礼物,生日过后他们决定分配这N个礼物(numv+numw=N).对于每一个礼物他们俩有着各自心中的价值vi和wi,他们要求各自分到的礼物数目|numv-numw|<=1,而且各自所衡量的礼物价值的差值|sumv-sumw|尽可能小,如今他们想知道最小的差值是多少.  Input 第一行为一个整数表示数据组数T. 接下来T组数组,每…
[BZOJ5498][十二省联考2019]皮配(动态规划) 题面 BZOJ 洛谷 题解 先考虑暴力\(dp\),设\(f[i][j][k]\)表示前\(i\)所学校,有\(j\)人在某个阵营,有\(k\)人在某个派系的方案数. 发现如果\(k=0\),那么可以先决策每个城市选择哪一个阵营,再对于每个学校选择哪一个派系.显然两者之间不冲突,分开\(dp\)再乘起来就行了. 加入限制,每个限制的形式即在某个城市选定了某个阵营之后,这个学校只有一种选择. 先把没有限制的部分处理完,首先这些学校单独拎出…