
数据结构
思考熊
这个作者很懒,什么都没留下…
展开
-
在文件夹下检索多个文件内容
import osimport re# 遍历指定目录,显示目录下的所有文件名def eachFile(filepath): pathDir = os.listdir(filepath) for allDir in pathDir: child = os.path.join('%s\%s' % (filepath, allDir)) if os.path.isfile(child): readFile(child) print(child.decode('gbk'))原创 2020-06-30 15:07:03 · 1764 阅读 · 0 评论 -
HihoCoder 1249(2015 Asia Beijing Regional Contest)
#include<stdio.h>#include<string.h>#include<math.h>#include<algorithm>using namespace std;long long int c[1001000];int lowbit(int i){ return i&(-i);}void add(int i,int w){ while(i<100原创 2016-10-09 19:38:56 · 464 阅读 · 0 评论 -
HDU 5122 K.Bro Sorting(2014亚洲区北京站现场赛)
水题#include<stdio.h>#include<algorithm>#include<string.h>#include<math.h>using namespace std;const int maxn=1000005;int a[maxn];int n;int main(){ int T,i,j,num=1; scanf("%d",&T); wh原创 2016-10-03 19:06:18 · 342 阅读 · 0 评论 -
HDU 5118 GRE Words Once More!(2014亚洲区北京站现场赛)
当年现场赛没人能做出来。受高人指点过掉。 G:#include <stdio.h>#include <vector>#include <map>#include <algorithm>using namespace std;#define SZ(V) ((int)((V).size()))#define MX_N 100001vector<int> edge[MX_N];vecto原创 2016-10-03 20:41:39 · 626 阅读 · 0 评论 -
HDU 5131 Song Jiang's rank list(2014亚洲区广州站现场赛)
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5131#include<iostream>#include<cstdio>#include<cstring>#include<cmath>#include<string>#include<algorithm>#include<queue>#include<stack>#incl原创 2016-10-04 16:39:04 · 364 阅读 · 0 评论 -
HDU 5135 Little Zu Chongzhi's Triangles(2014亚洲区广州站现场赛)
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5135#include<iostream>#include<cstdio>#include<cstring>#include<cmath>#include<string>#include<algorithm>#include<queue>#include<stack>#incl原创 2016-10-04 16:41:39 · 282 阅读 · 0 评论 -
全国信息学奥林匹克联赛(NOIP2016 )复赛模拟(三)
石头游戏 Marble【问题描述】 石头游戏的规则是这样的。 石头游戏在一个 n 行 m 列的方格阵上进行。每个格子对应了一个编号在 0~9 之间的操作序列。 操作序列是一个长度不超过 6 且循环执行、每秒执行一个字符的字符串。 它包括: 数字 0~9:拿 0~9 个石头到该格子。 NWSE:把这个格子内所有的石头推到相邻的格子。 D:原创 2016-10-06 20:46:07 · 1024 阅读 · 0 评论 -
全国信息学奥林匹克联赛(NOIP2016 )复赛模拟(二)
排序网络 Sorter 【问题描述】 最近 Henryy 公司推出了新型的排序网络。简单的来说,这种排序网络是由 一系列的的排序器按顺序组成。某个排序器可以将排序网络中[L,R]之间的输入 端进行排序。经过排序器处理后[L,R]之间排成非递减顺序。不同排序器的 L、R 值不同。 虽然排序网络很有用,但是很多情况下面我们可能只要排序网络中的最大 值,所以 Henryy 公司决定利用已有原创 2016-10-06 20:43:32 · 1136 阅读 · 0 评论 -
NOI 模拟试题(一)
智子入侵【题目背景】 三体发现了人类。 在疲于应付三个无法预测规律的太阳的时候,地球是他们唯一的希望。 为了限制住人类的基础物理研究,避免 300 年的技术爆炸,智子到达了地球。 目标:所有的粒子对撞机。 【题目描述】 作为三体人的科学执政官,元首需要你想他汇报智子每一次攻击的成果。军事执政官 已经把智子的攻击计划提交给你,而人类的一举一动也在智子的监视之下。你需要计算出 每一次智原创 2016-10-08 11:42:57 · 9343 阅读 · 0 评论 -
NOI 模拟试题(三)
阵列弱点【题目背景】 最后的会战:水滴对阵 n*m 架战舰。 悲剧的阵列喂饱了水滴,上百架战舰就是一串挂炮。 【题目描述】 抽象会战前的阵列为一个n*m的矩阵。每一个元素对应一个战舰。每一个战舰有一个 特征值。水滴希望找到一条特征值先下降后上升(可以只变大或者只变小)的路径(即一 个元素序列,满足相邻两个元素在阵列中的曼哈顿距离为1,或者说相邻两个元素上下左右 四连通,且每一个元素在原创 2016-10-08 11:49:05 · 3163 阅读 · 0 评论 -
HUD 5883 The Best Path(2016亚洲区青岛站网络赛)
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5883#include <cstdio>#include <cstring>#include <cmath>#include <ctime>#include <cstdlib>#include <queue>#include <stack>#include <string>#i原创 2016-09-17 18:26:27 · 346 阅读 · 0 评论 -
HDU 5882 Balanced Game(2016亚洲区青岛站网络赛)
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5882 水题,直接奇偶性判断即可。#include <cstdio>#include <cstring>#include <cmath>#include <ctime>#include <cstdlib>#include <queue>#include <stack>#incl原创 2016-09-17 18:23:07 · 526 阅读 · 0 评论 -
HDU 5878 I Count Two Three(2016亚洲区青岛站网络赛)
题目链接:http://acm.split.hdu.edu.cn/contests/contest_showproblem.php?pid=1001&cid=723#include <cstdio>#include <cstring>#include <cmath>#include <ctime>#include <cstdlib>#include <queue>#include <st原创 2016-09-17 18:16:36 · 515 阅读 · 0 评论 -
HDU-5037 Frog(2014亚洲区北京站网络赛)
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5037 M长的数轴,N个石头,青蛙每次跳动距离为L,求问跳到终点最多多少步#include<stdio.h>#include<cmath>#include<algorithm>#include<iostream>#include<string.h>typedef long long原创 2016-08-28 14:55:56 · 407 阅读 · 0 评论 -
九大排序算法的手写实现及时空复杂度分析 笔试面试必备
1、冒泡排序 冒泡排序是一种简单的排序方法,算法如下: 1. 首先将所有待排序的数字放入工作列表中。 2. 从列表的第一个数字到倒数第二个数字,逐个检查:若某一位上的数字大于他的下一位,则将它与它的下一位交换。 3. 重复2号步骤(倒数的数字加1。例如:第一次到倒数第二个数字,第二次到倒数第三个数字,依此类推…),直至再也不能交换。 用C语言实现如下:#include <iostream>原创 2016-08-19 11:08:55 · 4266 阅读 · 0 评论 -
Hrbust 1041 Chocolate Auction
并查集简单应用。原创 2016-01-18 13:56:24 · 388 阅读 · 0 评论 -
Hrbust 1160 病毒
并查集简单应用原创 2016-01-18 14:18:50 · 392 阅读 · 0 评论 -
poj-最多长方形数
题意:紧贴X轴有一些相互挨着的长方形,给定每个长方向的长和宽,求形成最大矩形是多少。#include<stdio.h>#include<stdlib.h>#include<stack>#include<iostream>#include<algorithm>using namespace std;struct node{ int a; int b;} aa;int原创 2016-08-20 16:29:26 · 495 阅读 · 0 评论 -
FZU 2105 线段树经典题目
#include <stdio.h>#include <iostream>#include <string.h>#include <math.h>#define N 1000010#define ls p<<1#define rs p<<1|1using namespace std;struct node{ int l,r; int cn;} aa[N<<2];vo原创 2016-04-02 22:54:05 · 463 阅读 · 0 评论 -
HDU5869 Different GCD Subarray Query(2016亚洲区大连站网络赛)
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5869 区间gcd数目查询,赛场上用树状数组预处理后一直超时,一直到比赛结束也没过去。后来用RNQ过掉。 AC 代码#include <cstdio>#include <cstring>#include <cmath>#include <ctime>#include <cstdli原创 2016-09-13 12:04:06 · 389 阅读 · 0 评论 -
Codeforces 363A Soroban-算盘模拟
You know that Japan is the country with almost the largest ‘electronic devices per person’ ratio. So you might be quite surprised to find out that the primary school in Japan teaches to count using a S原创 2016-09-15 12:18:45 · 462 阅读 · 0 评论 -
Codeforces 363B Fence-暴力
There is a fence in front of Polycarpus’s home. The fence consists of n planks of the same width which go one after another from left to right. The height of the i-th plank is hi meters, distinct plank原创 2016-09-15 12:25:37 · 715 阅读 · 0 评论 -
HLG 2015 千万次的问
Description现在给定一个数组array,数组的长度不会超过100000,而且数组中的每个元素都是一个正整数,每个元素的值不超过100000。对于一个给定的区间[a,b],我们想要知道数组array中有多少个元素落在这个区间内。a,b属于(0, 100000]。Input本题只有一组输入数据,首先输入一个整数n代表数组的长度,接下来输入n个正整数。之后需要输入一个正整数m表示询问的次数,m不原创 2016-08-17 10:13:37 · 390 阅读 · 0 评论