自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Enterprising Escape

Enterprising EscapeThe Enterprise is surrounded by Klingons! Find the escape route that has the quickest exittime, and print that time.Input is a rectangular grid; each grid square either has the Enterprise or some class of a Klingonwarship. Ass...

2021-05-06 12:33:42 92

原创 Expect the Expected

Some mathematical background. This problem asks you to compute the expected value of a randomvariable. If you haven’t seen those before, the simple definitions are as follows. A random variable is avariable that can have one of several values, each with

2020-12-24 13:29:51 290

原创 Tribles

GRAVITATION, n.“The tendency of all bodies to approach one another with a strengthproportion to the quantity of matter they contain – the quantity ofmatter they contain being ascertained by the strength of their tendencyto approach one another. This is

2020-12-24 10:04:26 125

原创 白兔的字符串

链接:https://ac.nowcoder.com/acm/problem/15253来源:牛客网白兔有一个字符串T。白云有若干个字符串S1,S2…Sn。白兔想知道,对于白云的每一个字符串,它有多少个子串是和T循环同构的。提示:对于一个字符串a,每次把a的第一个字符移动到最后一个,如果操作若干次后能够得到字符串b,则a和b循环同构。所有字符都是小写英文字母第一行一个字符串T(|T|<=10^6)第二行一个正整数n (n<=1000)接下来n行为S1~Sn (|S1|+|S2|+

2020-12-23 22:30:22 117

原创 Investigating Div-Sum Property

An integer is divisible by 3 if the sum of its digits is also divisible by 3. For example, 3702 is divisibleby 3 and 12(3+7+0+2) is also divisible by 3. This property also holds for the integer 9.In this problem, we will investigate this property for oth

2020-12-19 13:28:39 125 1

原创 字符串魔法(easy)

链接:https://ac.nowcoder.com/acm/contest/9680/B来源:牛客网白浅获得了一个仅由A和B组成的字符串。他可以至多使用一次魔法来改变字符串。 魔法的定义:选择一个字典序不递增的子串, 然后使得这个子串变成字典序不递减的子串,即变成形如AAA…AAABBB…BBB这样的字符串。 他想知道,在他至多使用一次魔法后,这个字符串能够出现的最长的字典序不递减的子串的长度为多少。输入描述:输入第一行包含一个整数n,代表字符串的长度接下来一行给出一个长度为n的字符串(1≤n≤

2020-12-10 12:38:26 1371

原创 全排列

链接:https://ac.nowcoder.com/acm/contest/9680/J来源:牛客网白浅经过一段时间对字符串的学习之后,学会了如何使用递归输出一个字符串的所有全排列(虽然 C++ 中有自带的函数),甚至学会了如何输出所有去重后的全排列(即“本质不同的全排列”)!她拿到了一个字符串 S,现在她将 S 的所有本质不同的全排列按字典序大小进行排序。假如总共有 k 个本质不同的字符串,则这些字符串按照字典序大小分别编号为 1.2.3…k,。白浅在这些字符串中任取了两个字符串 A B,现在她想知

2020-12-08 16:26:15 190

原创 爬塔(分组背包)

链接:https://ac.nowcoder.com/acm/contest/9680/F来源:牛客网高川最喜欢的游戏当属 Slay the Spire,这是一款爬塔游戏,你需要从一座塔的底部一直爬到顶部,在爬塔的过程中,塔的每一层都有许多的宝物等你来拿。高川从塔的左侧开始攀爬,从底部爬到顶部,再从右侧从顶部逐步下到底部。塔总共有 n 层,每一层都有很多宝物从左到右排列。在左侧攀爬时,他只能从每层的最左边按顺序取宝物,在右侧下降时,他只能从每层的最右边按顺序取宝物。每个宝物都有一个价值,他最多拿 m

2020-12-06 22:32:01 253

原创 Triangle

三分#include <stdio.h>#include <math.h>#include <algorithm>#include <string.h>using namespace std;double lz, lr, Lx, Ly, Rx, Ry, ans1, mid1, mid2, mid3, mid4, midx, midy, ans2, x1, x2, x3, p, q, y_1, y2, y3, l1, l2, l3;doubl...

2020-12-02 15:28:54 111

原创 XOR-gun

Arkady owns a non-decreasing array a1,a2,…,an. You are jealous of its beauty and want to destroy this property. You have a so-called XOR-gun that you can use one or more times.In one step you can select two consecutive elements of the array, let’s say x a

2020-11-30 22:10:51 109

原创 Cheerleaders(容斥原理)

In most professional sporting events, cheerleaders play a major role in entertaining the spectators. Theirroles are substantial during breaks and prior to start of play. The world cup soccer is no exception.Usually the cheerleaders form a group and perfo

2020-11-28 22:16:19 383

原创 Piotr‘s Ants

Piotr likes playing with ants. He has n of them on a horizontal pole L cm long. Each ant is facingeither left or right and walks at a constant speed of 1 cm/s. When two ants bump into each other, theyboth turn around (instantaneously) and start walking i

2020-11-23 09:37:14 106

原创 P2709 小B的询问(莫队)

#include <stdio.h>#include <algorithm>#include <string.h>#include <iostream>#include <math.h>using namespace std;int n, m, k, bbclock, a[1000001], cnt = 0, ans1 = 0;struct node{ int l, r, id;} b[1000001];int c[..

2020-11-20 16:26:03 79

原创 K-th Number(主席树)

K-th NumberTime Limit: 20000MS Memory Limit: 65536KTotal Submissions: 81684 Accepted: 29562Case Time Limit: 2000MSDescriptionYou are working for Macrohard company in data structures department. After failing your previous task about key insertion yo

2020-11-19 19:43:41 97

原创 Prefix Code(HASH+字典树)

对于给定的一串数字,看看是否有数字是其他数字的前缀。HASH把每一个数字的前缀和数字本身都转换成对应的数字保存到一个数组,排序为非递减序列,之后用对每一个数字进行二分查找,如果能够找到并且找到的数字大于等于2.则输出No,当全部数字都被判断完,并且全部不是其他字符前缀则输出Yes,当字符形式输入,处理0为开始情况。#include <stdio.h>#include <iostream>#include <algorithm>#include <st...

2020-11-16 13:32:53 416 6

原创 Color Graph

二分图的性质,不存在在奇环,一条边两端点在不同的集合,邻边不在同一边。dfs枚举两个集合点的选择,选这个点在左边集合则在右边就不存在。之后从所有的点的分配的情况中选一个合法边最多的情况。#include <iostream>#include <stdio.h>#include <string.h>#include <algorithm>#include<cmath>using namespace std;int u[10001..

2020-11-12 21:56:39 192

原创 E. Team-Building

去掉不合适的小组(自身包含奇环)的情况下的所有组的两两组合数目减去不合适的组合。并根据可撤销并查集不停的考虑不同的两组之间的组合是否合适,没进行下一组之前便把之前在上一个两组之间加上的边都去掉。如果两组之间连完边之后没有奇环的话就合适否则总数减一。用并查集确定二分图是否含有奇环。#include <stdio.h>#include <iostream>#include <string.h>#include <algorithm>using ...

2020-11-12 15:18:27 127

原创 D.Divide and Sum

对a的元素进行排序。将a的元素放到p,q两个队列中,对每一个元素对f的贡献值单独考虑。对于f(xi,yi)=|xi-yi|,当中大的数做正贡献,小的做负贡献。对于ai个元素假设前面有k个元素在p队列,则i-1-k个元素在q如果要ai有正贡献,则k>=n-(i-1-k);否则负贡献。如果在q队列中对于ai,设有k个在q队列中,则i-1-k个在q队列中,要做正贡献,则k>=n-(i-1-k)‘两个的结果的是i>n做正贡献,否则负贡献。所以对于所有的排列组合中,i>n的...

2020-11-08 22:32:20 100

原创 C - Shuffle Permutation(并查集+排列组合)

从行和列两方面考虑问题。1.从行,暴力遍历从第一行到最后一行,每两行的以元素,两两相加把每一个元素相加都小于k的两行都放到一个并查集,这里类似朋友的朋友也是朋友,如A与B符合条件,A与C符合条件,则A,B,C都在一个并查集,因为这里要利用通过变换能够得到多少不同种矩阵。只要在一个矩阵里就可以用排列组合的方式求有多少种分布方式。每一行中的不同并查集之间的分布种数通过相乘得到行通过变换可以得到多少种排列矩阵的方式。2.从列,与行相同。3.最后行的方式与列的方式相乘得到结果。#includ...

2020-11-08 22:18:50 180

原创 C. Division

#include <stdio.h>#define max(a, b) (a > b ? a : b)long long int ans = 1;void f(long long int p, long long int q,long long int x){ while (p % q == 0) { p /= x; } ans = max(ans, p);}int main(){#ifdef ONLINE_JUDGE#..

2020-11-03 21:55:58 148

原创 AtCoder-Quadruple

要求:1<=a,b,c,d<=n (1<n<1e5)a+b-c-d=k (-(2n-1)<=k<=(2n-1))->a+b-k=c+d;将a+b,c+d看作整体。A-k=B则B属于2-2*n;所以从1-1e5(最大)遍历A,只要A-k符合B的合法分为就将这个数记录下来。遍历完一遍以后处理所有统计的数字。要求,a,b,c,d都要大于等于1,小于等于n。遍历统计的数:a,b的取值,如果A<=n+1,则其中一点值可以从1取到A-1,对应A-...

2020-10-31 22:35:55 138

原创 高斯消元

顺序高斯消元#include <stdio.h>#include <string.h>double a[101][101];int main(){#ifdef ONLINE_JUDGE#else freopen("in.txt", "r", stdin);#endif int i, j, k, n, flag = 0, maxi = 0, maxv = 0; double u, v, ans = 0, x[101] = {0}, b[101],

2020-10-31 20:22:28 71

原创 ABB(马拉车)

#include <stdio.h>#include <string.h>#define max(a,b) (a>b?a:b)#define min(a,b) (a<b?a:b)char s[1000001],str[2000011];int k,len[2000011];void geter(int n){ int i,j; str[k++]='@'; for(i=0;i<n;i++) { s...

2020-10-30 21:02:35 104

原创 简单模板

1.快排struct node{ int id; long long int val;} a[1000001], e;int vis[1000001];void sort(int l, int r){ int left = l, right = r, i; int t = a[(l + r) >> 1].val; while (left <= right) { while (a[left].val < t &

2020-10-30 20:55:08 121

原创 PTAL2-001 紧急救援(dijkstra模板+求最短路径条数+求最短路径最大权值。)

L2-001 紧急救援 (25分)作为一个城市的应急救援队伍的负责人,你有一张特殊的全国地图。在地图上显示有多个分散的城市和一些连接城市的快速道路。每个城市的救援队数量和每一条连接两个城市的快速道路长度都标在地图上。当其他城市有紧急求助电话给你的时候,你的任务是带领你的救援队尽快赶往事发地,同时,一路上召集尽可能多的救援队。输入格式:输入第一行给出4个正整数N、M、S、D,其中N(2≤N≤500)是城市的个数,顺便假设城市的编号为0 ~ (N−1);M是快速道路的条数;S是出发地的城市编号;D是目的地

2020-10-27 19:58:34 178

原创 BeautyValues

代码#include <stdio.h>long long int dp[1000001], vis[1000001], a[1000001];int main(){#ifdef ONLINE_JUDGE#else freopen("in.txt", "r", stdin);#endif int i, j, n; long long int ans = 0; scanf("%d", &n); for (i = 1; i < ..

2020-10-27 17:16:44 73

原创 Grid Coloring

题目1000ms 26244KYou have an mm-by-nn grid of squares that you wish to color. You may color each square either red or blue, subject to the following constraints:• Every square must be colored.• Colors of some squares are already decided (red or blue), a

2020-08-17 18:45:29 284

空空如也

空空如也

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

TA关注的人

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