`
文章列表
#include<cstdio> #include<vector> using namespace std; const int MAX=100000; const int Max=2*50*50*50*50; struct node { int date; int num; }term; vector<node>v[MAX]; vector<node>::iterator it; int main() { // freopen("in.txt","r",stdin); ...
#include<stdio.h> int a[3200000]; int main() { int T,n,date; char str[10]; scanf("%d",&T); while(T--) { scanf("%s%d",str,&n); if(str[0]=='A') { while(n--) { scanf("%d",&date); a[date>>5]|=1<<(date%32 ...
    /* 字典树 */ #include<stdio.h> #include<string.h> #include<malloc.h> struct node { bool f; struct node*p[10]; }root; void init(node *p) { p->f=false; for(int i=0;i<10;i++) p->p[i]=NULL; } node * xin() { node *p =(node*)malloc(sizeof(node)); ...
/* 一个雪花是一个结构体,输入一个雪花先预处理一下 就是找出雪花的最小序列, 再用sort函数对雪花排序(利用运算符重载可以给结构体排序) 然后再找有没有重复的雪花 */ #include<cstdio> #include<algorithm> using namespace std; struct node { int a[6]; }xue[100010],term,term1,term2; bool operator < (const node &x,const node &y) { for(int i=0 ...
#include<stdio.h> #include<string.h> bool sushu[10010]; int map[110][110]; bool ves[110][110]; int fang[4][2]={1,0,-1,0,0,1,0,-1}; struct node { int x,y,step; }a,b,queue[10000]; int base,top; void f() { int i=1,j=1,term=10000; memset(map,0,sizeof(map)); while(term> ...
/* 做了一天题,现在已经昏昏沉沉了····· 先按矩形面积把小矩形从小到大排序,然后用动态规划做。 p[i]=max(p[1],p[2],p[3].....). p[i]为前i个矩形中可以嵌套的最多的矩形。 具体实现看代码! */ #include<stdio.h> #include<algorithm> struct JX { int a; int b; int date;//date里面存放这个矩形可以嵌套的最多的个数 }jx[1010]; bool neng(JX x,JX y)//判断x能否嵌套y(注意没有等于号!) ...
/* 比较简单的一道题,只要细心,思路清楚,基本都可以一遍过的 先把在地图上的实物数量化,墙是2,路是1,出界、河、铁墙都是-1 表示不能走。 然后用宽度遍历,起始点为队头,每次遍历上下左右四个方向 如果地图为-1,就不操作 如过地图不为-1,但没有遍历过,那么这块地图的步数应该是 队头地图的步数加上这块地图需要的步数。 如过地图不为-1,遍历过,那么这块地图的步数应该是 队头地图的步数加上这块地图需要的步数,和原来这块地图的 步数相比,最小的步数。 */ #include<iostream> #include<string.h> usin ...
/* 用队列来宽度搜索 初始状态先入队,一个有六种相互倒水的可能, 把这些没有出现过的状态全部入队,依次检查。 如果检查到结果状态,就输出 如果队列为空,就输出-1 */ #include<iostream> #include<map> using namespace std; map<int,int>mm;//用来标记是否用过 int queue[1000],base,top,result,ra,rb,rc,a,b,c,term; bool f(int &x,int &y,int rx,int ry)//把x 的水 ...
/* 如果是循环的,那么往后乘,必然会有和第一个相等, 如果不是循环的,那么往后乘,必然会有一个和第一个后面的相等, 而不是和第一个相等,所以先记录第一个,然后每乘一个都要看看有没有 和前面相等的出现,并且num++,直到出现为止。 如果出现了而不是和第一个相等,就输出-1 如果和第一个相等就输出num。 有一个问题: 怎么才能知道一个数出现过两次? (这里用到了map容器,可以很方便的知道一个数是否出现过, 看看下面代码就知道容器的用法啦!) */ #include<iostream> #include<map> using name ...
/* 这道题本来用广度递归来实现,编写完后发现AC不了,想想应该是 爆栈了,后来有改成用广度队列来写,可以AC啦! 思路是: 考虑到圈外的点肯定会和边框相交,所以就先把四条边的非0点入队, 入队一个点,就把这个点变成0, 然后在队列里面做第一个元素,找他的上下左右四个相邻非0点入队, 然后在队列里面做第二个元素,找他的上下左右四个相邻非0点入队, .............. 一直到top==base */ #include<stdio.h> #include<string.h> int map[965][1445];//存图 int qu ...
/* 思路:把每个房间编号换成走廊编号,然后算出每节走廊 用了多少次,最多的那一次就是至少用的时间, 可以开个200的数组存放每节走廊用的次数,具体代码看下面 */ #include<stdio.h> #include<string.h> int m[205];//走廊 int main() { // freopen("in.txt","r",stdin); int T,n,i,a,b,max; scanf("%d",&T); while(T--) { mem ...
/* 代码总体步骤是:(代码中的数字对应这些步骤) 1.先求出总和除以二为平均数 2.然后用母函数的代码 求出这些西瓜可以组成的 平均数一下的全部可能的重量 3.用bool数组把他们存起来 4.最后找出离平均数最近的那个数,就可以求出结果 */ #include<stdio.h> #include<string.h> int w[22]; int totle; bool p[100010]; int main() { int n,i,j,max; while(~scanf("%d",&n)) ...
连接: http://acm.nyist.net/JudgeOnline/problem.php?pid=15 括号匹配(二) 时间限制:1000 ms  |  内存限制:65535 KB 难度:6   描述 给你一个字符串,里面只包含"(",")","[","]"四种符号,请问你需要至少添加多少个括号才能使这些括号匹配起来。如:[]是匹配的([])[]是匹配的((]是不匹配的([)]是不匹配的   输入 第一行输入一个正整数N,表示测试数据组数(N<=10)每组测试数据都只有一 ...
连接:   http://acm.nyist.net/JudgeOnline/problem.php?pid=10 skiing 时间限制:3000 ms  |  内存限制:65535 KB 难度:5   描述 Michael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。Michael想知道载一个区域中最长底滑坡。区域由一个二维数组给出。数组的每个数字代表点的高度。下面是一个例子 1 2 3 4 516 17 18 19 615 24 25 20 714 23 22 21 8 ...
  #include<iostream> #include<map> using namespace std; typedef struct { int x; int w; char s; }aaa; map<int,int>a; aaa dui[1000000],du[1000000];//两个队列 char www[1000000]; int main() { int i,j; int many,ji,ji1,zan,zan2,x,y,tt,ww,ta,wa,q; int fang1[4][2]={-1,0 ...
Global site tag (gtag.js) - Google Analytics