- 博客(24)
- 收藏
- 关注
转载 Codeforces Round #419 (Div. 2) C. Karen and Game
C. Karen and Gametime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputOn the way to school, Karen became fixated o...
2017-06-18 11:52:00
136
转载 uva10570(Meeting with Aliens)
因为环状序列一定是递增或者递减,数据范围不大,所以直接枚举所有环状序列逐个计算需要的交换次数,取最小即可。交换的时候贪心策略是总是先把一个数换到应有的位置上。因为这样n次至少可以让n个数归位,而如果一次想让两个数归位,则至少需要通过传递交换两次,也是相当于一次让一个数归位。 1 #include <stdio.h> 2 #include <iostr...
2017-05-25 17:03:00
123
转载 UVA10118Free Candies
一开始看数据范围不大想直接暴力搜索,仔细考虑搜索的状态会有很多重复,搜索量仍然很大。这就是传说中的记忆化搜索。。。number数组表示每一列取了多少个数,ans每一列取得相应数字个数时的最优解。第九章前面的代码用了引用,在记忆化搜索里面很方便。这个题还要注意搜索的时候要回溯,搜不下去了要尝试另一种。 1 #include <stdio.h> 2 #incl...
2017-05-23 23:26:00
127
转载 UVA 12563(Jin Ge Jin Qu hao)
开始认真学DP。我对滚动数组的理解是:后一个状态可以由前一个状态求得,便可以使用一维数组重复利用节省空间复杂度。这个题要注意题目要求的前提,求次数可以看作重量为v[i]价值为1放入w-1的背包,歌曲就是重量和价值都是v[i],简单的转化。#include <iostream>#include <bits/stdc++.h>using nam...
2017-05-13 00:31:00
120
转载 省赛总结
NCC_31060 HsiaoYeekwan这是我参加的第一次真正意义上的ACM大赛,虽然只是友情参赛,但也真正体验到了竞赛的氛围。首先要感谢教主和其他的老师,能够让我有这次参赛的机会,然后感谢我的学长学姐给予我的指导和帮助,还有我的队友,和我一直坚持着。来到青科,住宿条件还可以,伙食不敢恭维,志愿者不错。热身赛做出了A题但是在C题卡死了,然后最后半个多小时测试了一下机器,P...
2017-05-13 00:24:00
95
转载 Codeforces 748B Santa Claus and Keyboard Check
Santa Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he suddenly realized that some pairs of keys took each other's place! That is, Santa suspects tha...
2017-02-26 22:37:00
105
转载 UVA12545(比特转换器)。
贪心的思想,如果S串是1而t串是0,只能够交换。除去相同的部分,如果上面的1比下面的1多,就无法变换成功,输出-1. 1 #include <bits/stdc++.h> 2 3 using namespace std; 4 const int maxn = 100+10; 5 int main() 6 { 7 char s[maxn...
2017-02-12 14:32:00
142
转载 UVA1149(装箱)
基本贪心思想,因为只能装两个,所以肯定优先装最重的,再装最轻的。输出格式有点坑。 1 #include <bits/stdc++.h> 2 3 using namespace std; 4 5 int main() 6 { 7 int t,n,i,m; 8 int a[100860]; 9 cin >...
2017-02-06 14:31:00
125
转载 UVA120(煎饼)
这个题唯一坑爹的地方就是UVA给的udebug数据是错的,害得我头疼了半天。。。思路就是依次找最大的数把它转到最低端,每次执行的时候判断一下是否已经符合题意,符合则跳出循环。 1 #include <iostream> 2 #include <algorithm> 3 #include <cstdio> 4 #inclu...
2017-02-06 13:55:00
163
转载 uva232(纵横字谜)。
book数组用来判断起始点。PR了四次,迷之换行。。。 1 #include <iostream> 2 #include <algorithm> 3 #include <cstdio> 4 #include <vector> 5 #include <cmath> 6 #include <cs...
2017-02-03 01:03:00
103
转载 uva1589(象棋)。
这个题昨天晚上做到一点半还是WA,早上起来后认真思考了一下终于AC....细节比较多,我第一次AC的代码写了350多行,我考虑了黑将能吃子的情况,我把那种情况去掉后也可以AC,应该没有很BT的数据。思路就是弄两个二维数组,一个模拟红棋可以杀的范围,另一个模拟黑将到达的位置,再判断是否处于红棋击杀范围之内就好了。第一次AC的代码太长,下面是第二次AC的代码(把黑将能吃子的情...
2017-02-01 13:08:00
155
转载 UVA12108(特别困的学生)。
参考了一下百度。。。 1 #include <iostream> 2 #include <cstdio> 3 #include <cstdlib> 4 #include <algorithm> 5 #include <cstring> 6 7 using namespace std; 8 c...
2017-01-31 20:03:00
105
转载 uva712(s树)
这个题就是考完全二叉树的性质。输入的x1,x2,x3没卵用,读题读了半天。。。 1 #include <iostream> 2 #include <string> 3 #include <vector> 4 #include <algorithm> 5 #include <cstdio> 6 #inc...
2017-01-23 23:14:00
79
转载 POJ1338丑数(uva136)
UVA书上用的set,poj上这个题我用的vector。 1 #include <iostream> 2 #include <string> 3 #include <vector> 4 #include <algorithm> 5 #include <cstdio> 6 #include <cs...
2017-01-23 22:25:00
101
转载 UVA815(洪水)。
关键就是给海拔排个序,找出有多少快地低于水平面。要注意n=m=1的情况,和100%的情况。 1 #include <iostream> 2 #include <cstdio> 3 #include <cstdlib> 4 #include <string> 5 #include <vector> ...
2017-01-21 00:43:00
195
转载 UVA1590(IP网络)
被数据结构弄的怀疑人生了...做个水题找一下自信!之前培训过一点网络的基础,所以这个题比较容易。直接上代码。 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 #include <ctype.h> 5 #include <m...
2017-01-20 23:43:00
162
转载 uva12100(打印队列)
直接模拟就好了,注意一下结束的条件。 1 #include <iostream> 2 #include <algorithm> 3 #include <string> 4 #include <queue> 5 #include <cstdio> 6 #include <vector> ...
2017-01-17 12:00:00
143
转载 uva10391(复合词)
第一次做是用暴力的方法一个一个找,意料之中超市了;然后就想把每个单词拆分,虽然时间复杂度也是平方级别,但是单词不会太长,循环次数小很多,试过之后果然AC了! 1 #include <iostream> 2 #include <queue> 3 #include <cstring> 4 #include <algorithm...
2017-01-17 00:10:00
109
转载 UVA 10622(完全P次方数)。
要考虑负数,还要考虑超时,改了三四遍才过......其实就是暴力,稍微处理一下就不会超时了。 1 #include <iostream> 2 #include <algorithm> 3 #include <cstdio> 4 #include <cstdlib> 5 #include <cmath>...
2017-01-13 22:39:00
121
转载 UVA1644(素数间隔)。
打个表,挨个找就可以了。 1 #include <iostream> 2 #include <algorithm> 3 #include <cstring> 4 #include <cstdio> 5 #include <cstdlib> 6 #include <cmath> 7 ...
2017-01-13 21:35:00
214
转载 UVA1210(连续素数和)。
继续寻找水题。。。把所有的素数存进一个数组,然后用递归的方法做比较简单。 1 #include <iostream> 2 #include <algorithm> 3 #include <cstring> 4 #include <cstdio> 5 #include <cstdlib> 6 #in...
2017-01-13 21:32:00
128
转载 UVA1595(对称轴)。
最近在上别的课,没时间深入学c++和数据结构,所以专门挑了一些简单题练练手。按照横坐标排序,找出对称轴,然后枚举每个点是否关于这条直线对称;如果不对称把横坐标存入数组,如果这个店不在对称轴上面的话就输出NO。 1 #include <iostream> 2 #include <algorithm> 3 #include <cstdio...
2017-01-12 11:42:00
194
转载 UVA253(骰子涂色)
分别把1.6,2.5,3.4看作底面,有三种变换,自己画个图就很简单了。写三个变换的函数,枚举所有的变换情况,如果在变换过程中出现与原串相同,就为true。 1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 #include <cstdli...
2017-01-11 23:03:00
123
转载 UVA1588(Kickdown)。
只需要固定长串,拿着短串移动就好了。我是从右往左移动,需要注意的是要判断两头重叠部分(左端重叠和右端重叠)的大小关系。 1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 #include <cstdlib> 5 #include ...
2017-01-09 23:18:00
115
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人