随笔分类 - ——STL
摘要:题目链接题意:有一个n*m的田地,里边有k棵树,每棵树的位置为(xi,yi),含有能量值ci。之后又q个询问,分三种;1)1 a b,将a行和b行交换2)2 a b,将a列和b列交换3)3 a b,询问(a,b)位置的果树的能量值。分析:由于n和m很大,而k很小,所以可以用map离散化。每次交换行或...
阅读全文
摘要:题目:http://poj.org/problem?id=2418在poj 上交题总是有各种错误,再次感叹各个编译器。c++ AC代码,G++为超时,上代码: 1 #include 2 #include 3 #include 4 using namespace std; 5 6 char s[100]; 7 int main() 8 { 9 mapmp;10 map::iterator iter;//声明迭代器11 int sum=0;12 while(gets(s)!=NULL)13 {14 mp[s]++;...
阅读全文
摘要:题目:http://poj.org/problem?id=2442题意:给你n*m的矩阵,然后每行取一个元素,组成一个包含n个元素的序列,一共有n^m种序列,让你求出序列和最小的前n个序列的序列和。 又是一个机智的题 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include10 #include11 #include12 using namespace std;13 14 int a[20000],b[20000];15 int main()16 {17.
阅读全文
摘要:题目:http://poj.org/problem?id=1442题意:n,m,分别是a数组,u数组的个数,u[i]w为几,就加到a几,然后输出第i 小的刚开始用了一个小顶堆,超时,后来看了看别人的 代码,很巧妙的设计 1 #include 2 #include 3 4 using namespace std; 5 6 int a[40000]; 7 int main() 8 { 9 int n,i,m,j,u;10 priority_queue,less > maxhead;11 priority_queue,greater > minhead;12 sc...
阅读全文
摘要:http://www.cnblogs.com/bigcat814/ http://blog.sina.com.cn/s/blog_7065a9de010154ve.html 堆 http://www.cppblog.com/MiYu/archive/2010/09/01/125539.html 以下
阅读全文
摘要:题目:http://poj.org/problem?id=3096 题意:给定一个字符串S,从中找出所有有两个字符组成的子串,每当组成子串的字符之间隔着n字符时,如果没有相同的子串出现,则输出 "S is surprising." , 反之,则输出 "S is NOT surprising." 。
阅读全文
摘要:简单例题题目:http://acm.hdu.edu.cn/showproblem.php?pid=1412list 相关博客:http://www.cnblogs.com/fangyukuan/archive/2010/09/21/1832364.html 1 #include 2 #inclu...
阅读全文
摘要:题目:题意:题意:给出几个正数(2~15个),然后就是求有这些数字的2倍有没有和原先的正数相同的,求出有几个,没有就是0.分析:水题。用数组解决,开一个数组存正数,另开一个数组用来存这些数的2倍,接着就搜索,然后注意一下结束的时候怎么处理就行。c普通方法: 1 #include 2 #includ...
阅读全文
摘要:c++ sort :http://www.16kan.com/post/997260.html http://wenku.baidu.com/view/e064166daf1ffc4ffe47ac67.html 假设自己定义了一个结构体 node struct node { int a; int b
阅读全文
摘要:题目题解:http://blog.csdn.net/xu12110501127/article/details/9199335 有关博客:http://www.360doc.com/content/10/1118/16/963301_70454649.shtml 优先队列不错的博客。 priorit
阅读全文

浙公网安备 33010602011771号