自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(81)
  • 收藏
  • 关注

原创 NYOJ - 82 - 迷宫寻宝(一)(多次bfs)

题解:其实这个题和普通的bfs差不多主要对钥匙的处理如果到不了目的地,有可能是被门给挡住了,那么就去找钥匙用bfs去走全图,一旦遇到宝藏就一切都结束,输出YES如果走遍了全图还没有见到宝藏,那么一定是门或墙阻挡了你见到宝藏的道路,但你这一次开不了门,并不代表下一次你就开不了门,所以一旦这次bfs结束,你手中的钥匙有增加,那么,在下一次bfs中,你或许就能打开门啦(也就是有找到宝藏的希望...

2018-08-31 21:57:22 235

原创 Ball King(线段树或dp)

题目描述HPU601球王争霸赛即将举行,ACMER纷纷参加.现在有n个人报名参赛,每个人都有一个实力值 ai,实力值较大者获胜.为保证比赛公平,我们定义比赛规则:第一轮:[1, 2]pk,然后[3, 4]pk...最后[2i − 1, 2i]pk.第二轮:[1, 2]W inner同[3, 4]W inner进行pk,然后[5, 6]W inner同[7, 8]W inner......

2018-08-30 21:58:54 168

原创 Color ring(dfs)

Description Input Output Sample Input 1 3 4AAAAABCAAAAASample Output 1Yes  #include<cstdio>#include<cstring>#include<algorithm>#include<iostr...

2018-08-30 20:24:34 129

原创 money

题解:考虑一个连续的段,长度为l,如果该段的区间和为0的话,那么就操作l-1次就够了现在有n个数,你分成了k段,那么你就需要操作n-k次那么只要k最大就好了然后暴力枚举前缀和相等的,取最大就好了Description Input Output Sample Input 1 335 0 -54-1 0 1 041 2 3 -6...

2018-08-30 18:02:52 123

原创 Happy Path(dfs)

题解:现在总结一下unique,unique的作用是“去掉”容器中相邻元素的重复元素(不一定要求数组有序),它会把重复的元素添加到容器末尾(所以数组大小并没有改变),而返回值是去重之后的尾地址,vector函数的erase函数erase函数可以用于删除vector容器中的一个或者一段元素,在删除 。第一个参数为删除的首地址,第二个参数为删除的末位置。 Input Out...

2018-08-30 15:58:55 997

原创 问题(dfs)

 问题Description Input Output Sample Input 1 23 5 6 11 2 34 40 50 1010 20 30 25Sample Output 1#include <stdio.h>#include <algorithm>using namespace std;...

2018-08-28 21:10:57 195

原创 Different Rectangle

Different RectangleDescription Input Output Sample Input 1 12 3HPUUHPSample Output 16#pragma GCC optimize ("O3")#pragma GCC optimize ("O2")#include <bits/stdc++....

2018-08-28 20:15:10 174

原创 吝啬的国度

题解:本题运用了vector建图,vector<int>e[maxn] ,e[u][i]表示i从0开始的,第i个的父节点(即为e[u][i]的父节点)为u的点,这个是关键,以前这个细节都忽略了,pre[x],表示x的父节点。描述在一个吝啬的国度里有N个城市,这N个城市间只有N-1条路把这个N个城市连接起来。现在,Tom在第S号城市,他有张该国地图,他想知道如果自己要去参观第...

2018-08-27 18:44:01 107

原创 与程序竞赛有关的数学知识点

https://blog.csdn.net/ctsas/article/details/55000318这个博客写的特别好,而且内容丰富。莫比乌斯函数莫比乌斯函数μ(n),在狄利克雷卷积的乘法中与恒等函数互为逆元,μ(1)=1,μ(4)=1,对于无平方因子数有,t为因子个数。对于有平方因子数 有μ(n)=0 。代码实现: int exGcd(int a,int b,int &...

2018-08-24 23:04:33 177

原创 地狱飞龙 [simpson][积分

题目描述最近clover迷上了皇室战争,他抽到了一种地狱飞龙,很开心。假设地域飞龙会对距离为d的敌人每秒造成k/d2伤害。假设地域飞龙位于坐标轴原点,以每秒v1的速度向y轴正方向移动,敌人在(x,0)的位置,以每秒v2的速度向x轴负方向移动。问,敌人至少有多少血量永远才不会被地狱飞龙喷死。(伤害是连续造成的,不是一秒一秒间断的)输入第一行为数据组数T(1<=T<=1000)...

2018-08-24 20:55:29 274

原创 Leading and Trailing [数学]

方法:a^k=10^(lga^k)=10^k(⋅lga)=10^([k⋅lga]+{k⋅lga})前n位:10^(n−1)⋅10^{k⋅lga}You are given two integers: n and k, your task is to find the most significant three digits, and least significant three dig...

2018-08-24 19:28:37 118

原创 lightoj 1341 Aladdin and the Flying Carpet (唯一分解定理)

Aladdin and the Flying Carpet PDF (English) Statistics Forum Time Limit: 3 second(s) Memory Limit: 32 MB It's said that Aladdin had to solve seven mysteries beforegetting the Magical...

2018-08-24 17:57:19 135

原创 51Nod - 1126 求递推序列的第N项

#include <stdio.h>#include <string.h>#define maxn 3#define mod 7using namespace std;typedef long long ll;int N;ll b_n=0,c[maxn],h[maxn];struct matrix{ ll m[maxn][maxn];};matrix...

2018-08-24 16:06:42 104

原创 HDU 1166 敌兵布阵

#include <stdio.h>using namespace std;#define ls o<<1#define rs o<<1|1const int MAXN = 2e5+10;int a[MAXN];struct node{ int l,r; int x;}t[MAXN<<2];inline void push_up...

2018-08-22 21:02:15 146

原创 【P1531】I Hate It - 洛谷 单点更新板子题

#include <stdio.h>#include <algorithm>using namespace std;#define maxn 200010 #define ls o<<1#define rs o<<1|1int a[maxn];struct node{ int l,r,x;}t[maxn<<2];in...

2018-08-22 20:59:44 271

原创 POJ 3468 【线段树区间更新】

为了解决这个问题 著名的Lazy-Tag思想应运而生每次都把所有区间修改了太慢了 不如懒一点 先把帐记着 到时候再做懒-记帐=Lazy-Tag怎么记录呢? 我们需要再加一个  lazy 标记用来记录当前节点为根的子树 是否需要统一加一个数 具体要加多少我们的程序就要改一下了  +每当碰到要当前区间完全被欲修改区间覆盖时 直接给加在标记上 然后退出  +每次访问到一个...

2018-08-22 15:29:03 137

原创 Stammering Aliens (Hash+二分)

Dr. Ellie Arroway has established contact with an extraterrestrial civilization. However, all efforts to decode their messages have failed so far because, as luck would have it, they have stumbled upo...

2018-08-18 21:09:28 380 1

原创 Period (KMP)

#include <stdio.h>#include <string.h>#define maxn 1000010char a[maxn];int nxt[maxn];int n;void getnxt(){ nxt[0]=0; int i=1,j=0; while(i<n) { if(a[i]==a[j]) { nxt[i++]...

2018-08-18 17:34:37 235

原创 Power Strings (KMP)

#include<stdio.h>#include <string.h>#define maxn 1000010char a[maxn];int nxt[maxn];int len;void getnxt(){ int i=1,j=0; nxt[0]=0; while(i<len) { if(a[i]==a[j]) { ...

2018-08-18 17:32:35 190

原创 Seek the Name, Seek the Fame (KMP) 和(HASH)两种方法

#include <stdio.h>#include <string.h>#define maxn 400010char a[maxn];int nxt[maxn] ;int len;void getnxt(){ nxt[0]=0; int i=1,j=0; while(i<len) { if(a[i]==a[j]) { nxt[...

2018-08-18 17:30:35 1281 2

原创 剪花布条 (KMP)

一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案。对于给定的花布条和小饰条,计算一下能从花布条中尽可能剪出几块小饰条来呢? Input输入中含有一些数据,分别是成对出现的花布条和小饰条,其布条都是用可见ASCII字符表示的,可见的ASCII字符有多少个,布条的花纹也有多少种花样。花纹条和小饰条不会超过1000个字符长。如果遇见#字符,则不再进行工作。 Output...

2018-08-18 13:49:41 171

原创 Oulipo(KMP)

The French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter 'e'. He was a member of the Oulipo group. A quote from the book: Tout avait Pair normal, mais tout s’...

2018-08-18 13:47:14 168

原创 Number Sequence (KMP模板)

Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b[2], ...... , b[M] (1 <= M <= 10000, 1 <= N <= 1000000). Your task is to find a number K which make a[K] = b[1], a[K ...

2018-08-18 13:45:11 123

原创 Aggressive cows (二分)

#include <stdio.h>#include <algorithm>using namespace std;int a[100009];int n;int judge(int t){ int p=a[0],ans=1; for(int i=1;i<n;i++) { if(a[i]-p>=t)//找寻两点距离大于等于x的数量 {...

2018-08-17 21:04:00 228

原创 Crazy Search (hash)

#include <stdio.h>#include <algorithm>//#include <map>#include <string.h>char a[16000006];using namespace std; int vis[600],hash[16000005];//内存都可以超,时间也要注意,有可能超;//其实我有点...

2018-08-17 16:45:44 127

原创 Oulipo(hash 模板)

#include <stdio.h>#include <algorithm>#include <string.h>#include <string>using namespace std; typedef unsigned long long ull;//ull具有自我取模的特性 #define mod 1000000007ull c...

2018-08-17 16:41:52 207

原创 Constructing Roads(克鲁斯卡尔)

#include <stdio.h>#include <algorithm>#define INF 0x3f3f3f3fusing namespace std;int father[510],co[510][510]; struct node{ int u,v,w;}qwe[250000];bool cmp(node a,node b) { retur...

2018-08-16 23:19:37 214

原创 畅通工程再续 (库里斯卡尔算法)

#include <stdio.h>#include <math.h>#include <algorithm>using namespace std;int father[120];struct node{ double x,y;}qwe[120];struct po{ int u, v; double w;}asd[50000];bo...

2018-08-16 16:58:26 248

原创 Cube Stacking

#include <stdio.h>int father[30011],deep[30011],h[30011];//数组H[i]表示i下有多少个方块 ,deep[i]表示i所在栈堆的高度 int find(int x){ if(x!=father[x]) { int t=father[x]; father[x]=find(father[x]); h[x]+=h...

2018-08-15 21:17:14 883

原创 Dragon Balls

#include <stdio.h>#include <algorithm>using namespace std;int father[10011],m[10011],num[10011];int n,q;//数组m表示转移次数 ,num[]表示节点数 int find(int x){ if(x!=father[x]) { int t=fath...

2018-08-15 17:56:50 145

原创 How Many Tables

#include <stdio.h>int father[1010];int find(int x){ while(x!=father[x]) { x=father[x]; } return x;}void join(int x,int y){ x=find(x); y=find(y); if(x!=y) { father[x]=y; }...

2018-08-15 15:36:26 132

原创 还是畅通工程

//我感觉这个方法挺好的,不过我目前还想不到。。。。 #include <stdio.h>#include <algorithm>using namespace std;int father[1010];struct path{ int a,b,l;}qwe[10000];bool cmp(path c,path d){ return c.l<d...

2018-08-15 15:00:34 187

原创 The Suspects (并查集)

#include <stdio.h>int father[30011],rank[30011];int find(int x){ if(x!=father[x]) { father[x]=find(father[x]); } return father[x];}int main(){ int n,m,a,b,t; while(scanf("%d%d",&a...

2018-08-15 11:10:41 174

原创 畅通工程 (并查集模板)

#include <stdio.h>int father[1010];int find(int c)//查找父节点 { int r=c; while(father[r]!=r) r=father[r]; return r;}void join(int a,int b)//建立新关系 { int fa=find(a); int fb=find(b);...

2018-08-15 10:03:52 236 3

原创 Silver Cow Party (djk最短路)

#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;#define N 1010#define M 100010#define INF 0x3f3f3f3fint n,m,x;int mp[N][N];int dis1[N],dis2[N];...

2018-08-14 23:59:59 137

原创 畅通工程续(djk+优先队列)

#include <stdio.h>#include <queue>#include <string.h>using namespace std;typedef pair<int,int>pii;#define N 100011#define M 1000011#define INF 0x3f3f3f3fstruct Edge{//...

2018-08-14 22:23:22 180

原创 Til the Cows Come Home (最短路(Dijkstra,Dijkstra+优先队列,Floyd))

#include <stdio.h>#include <iostream>#include <queue>#include <string.h>using namespace std;#define N 1011#define INF 0x3f3f3f3fint n,m;int mp[N][N];void init(int n)...

2018-08-14 21:10:36 420

原创 Ball

#include <stdio.h> #include <iostream>typedef long long ll;//#define long long ll//#define unsigned long long ull#define po 1000000007int block=500000;int f[4000] = {1,154425679,6...

2018-08-13 22:10:46 160

原创 Add one minus one

#include <stdio.h> #include <algorithm>using namespace std;int a[1100];int main(){ int t; scanf("%d",&t); while(t--) { int n,sum=0; scanf("%d",&n); for(int i=0;i&lt...

2018-08-13 15:46:32 154

原创 P1508 Likecloud-吃、吃、吃

#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;#define maxn 220int a[maxn][maxn],dp[maxn][maxn],vis[maxn][maxn];/*int d[3][2]={-1,0,-1,-1,-1,1},m...

2018-08-11 22:39:32 121

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除