自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 D. Let‘s Go Hiking (思维,博弈)

On a weekend, Qingshan suggests that she and her friend Daniel go hiking. Unfortunately, they are busy high school students, so they can only go hiking on scratch paper.A permutation p is written from left to right on the paper. First Qingshan chooses an

2021-05-14 19:51:34 263

原创 Problem L. Little Difference

Problem L. Little DifferenceInput file: little.in Time limit: 3 secondsOutput file: little.out Memory limit: 512 megabytesLittle Lidia likes playing with numbers. Today she has a positive integer n, and she wants to decomposeit to the product of positi

2021-05-07 19:31:31 171

原创 Simone and graph coloring(最长下降子序列)

比赛的时候,用线段树做的。之后发现,这题就是一个裸的最长下降子序列的题目。主要难点是它的n的范围是1e6,要优化为nlogn级别。#include <bits/stdc++.h>#define inf 0x3f3f3f3fusing namespace std;typedef long long LL;const int N = 1e6 + 10;int n, top, c, t;int ans[N], a[N];int main() { scanf("%d", &a.

2021-04-27 10:16:04 205

原创 L1-8 估值一亿的AI核心代码 (20 分)

本题要求你实现一个稍微更值钱一点的 AI 英文问答程序,规则是:无论用户说什么,首先把对方说的话在一行中原样打印出来;消除原文中多余空格:把相邻单词间的多个空格换成 1 个空格,把行首尾的空格全部删掉,把标点符号前面的空格删掉;把原文中所有大写英文字母变成小写,除了 I;把原文中所有独立的 can you、could you 对应地换成 I can、I could—— 这里“独立”是指被空格或标点符号分隔开的单词;把原文中所有独立的 I 和 me 换成 you;把原文中所有的问号 ? 换成惊叹号

2021-04-23 10:51:29 148

原创 L3-010 是否完全二叉搜索树 (利用数组简化操作)

L3-010 是否完全二叉搜索树 (30 分)将一系列给定数字顺序插入一个初始为空的二叉搜索树(定义为左子树键值大,右子树键值小),你需要判断最后的树是否一棵完全二叉树,并且给出其层序遍历的结果。输入格式:输入第一行给出一个不超过20的正整数N;第二行给出N个互不相同的正整数,其间以空格分隔。输出格式:将输入的N个正整数顺序插入一个初始为空的二叉搜索树。在第一行中输出结果树的层序遍历结果,数字间以1个空格分隔,行的首尾不得有多余空格。第二行输出YES,如果该树是完全二叉树;否则输出NO。输入样例

2021-04-22 09:36:15 79

原创 Patches (思维+搜索)

PatchesCarlos is very concerned with the environment. Whenever possible, he tries to use less pollutingmeans of transport. He recently got a job close to home and is now using his bike to go to work.Unfortunately, in the route between his home and his j

2021-03-31 15:14:28 177

原创 E - Flow

One of Pang’s research interests is the maximum flow problem.A directed graph G with n vertices is universe if the following condition is satisfied:G is the union of k vertex-independent simple paths from vertex 1 to vertex n of the same length.A set of

2021-03-29 18:10:29 333

原创 Galactic Collegiate Programming Contest

One hundred years from now, in 2117, the International Collegiate Programming Contest (of which the NCPC is a part) has expanded significantly and it is now the Galactic Collegiate Programming Contest (GCPC).This year there are n teams in the contest. The

2021-03-27 19:20:08 107

原创 L2-034 口罩发放 (25 分)

L2-034 口罩发放 (25 分)为了抗击来势汹汹的 COVID19 新型冠状病毒,全国各地均启动了各项措施控制疫情发展,其中一个重要的环节是口罩的发放。某市出于给市民发放口罩的需要,推出了一款小程序让市民填写信息,方便工作的开展。小程序收集了各种信息,包括市民的姓名、身份证、身体情况、提交时间等,但因为数据量太大,需要根据一定规则进行筛选和处理,请你编写程序,按照给定规则输出口罩的寄送名单。输入格式:输入第一行是两个正整数 D 和 P(1≤D,P≤30),表示有 D 天的数据,市民两次获得口罩的

2021-03-24 21:07:59 929

原创 Secret Santa (错排)

Christmas comes sooner every year. In fact, in one oft-forgotten corner of the world, gift-giving has already started in the form of a Secret Santa syndicate.Everybody in the small town of Haircombe is going to put their name into a hat. This hat will be

2021-03-24 15:03:16 293

原创 Book Club (tarjan算法)

Book ClubPorto’s book club is buzzing with excitement for the annual book exchange event!Every year, members bring their favoritebook and try to find another book they likethat is owned by someone willing to tradewith them.I have been to this book ex

2021-03-22 16:53:20 194

原创 1358. 约数个数和 (莫比乌斯反演,双整数分块)

约数个数和设 d(x) 为 x 的约数个数,给定 N,M,求∑i=1N∑j=1Md(ij)输入格式输入多组测试数据。第一行,一个整数 T,表示测试数据的组数。接下来的 T 行,每行两个整数 N、M。输出格式T 行,每行一个整数,表示你所求的答案。数据范围1≤N,M,T≤50000输入样例:27 45 6输出样例:110121#include <bits/stdc++.h>using namespace std;const int N = 50010;.

2021-03-18 21:06:46 109

原创 L2-001 紧急救援 (25 分) (最短路)

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

2021-03-11 20:46:49 132

原创 361. 观光奶牛

观光奶牛给定一张L个点、P条边的有向图,每个点都有一个权值f[i],每条边都有一个权值t[i]。求图中的一个环,使“环上各点的权值之和”除以“环上各边的权值之和”最大。输出这个最大值。注意:数据保证至少存在一个环。输入格式第一行包含两个整数L和P。接下来L行每行一个整数,表示f[i]。再接下来P行,每行三个整数a,b,t[i],表示点a和b之间存在一条边,边的权值为t[i]。输出格式输出一个数表示结果,保留两位小数。数据范围2≤L≤1000,2≤P≤5000,1≤f[i],t.

2021-03-08 19:37:19 88

原创 1145. 北极通讯网络 (思维,并查集)

北极通讯网络北极的某区域共有 n 座村庄,每座村庄的坐标用一对整数 (x,y) 表示。为了加强联系,决定在村庄之间建立通讯网络,使每两座村庄之间都可以直接或间接通讯。通讯工具可以是无线电收发机,也可以是卫星设备。无线电收发机有多种不同型号,不同型号的无线电收发机有一个不同的参数 d,两座村庄之间的距离如果不超过 d,就可以用该型号的无线电收发机直接通讯,d 值越大的型号价格越贵。现在要先选择某一种型号的无线电收发机,然后t统一给所有村庄配备,数量不限,但型号都是 相同的。配备卫星设备的两座村庄.

2021-03-05 17:25:36 118

原创 Chess Tournament(并查集+拓扑排序)

Chess TournamentYour friend is an organizer of the International Chess Playing Championship. He is worried that some of the contestants may be cheating, and he has asked you to help out. The chess players are allowed to report matches to the jury themselv

2021-03-04 16:28:36 424 1

原创 Bobby‘s Bet(概率)

obby and Betty have a bet. Betty bets Bobby that he cannot roll an S-sided die (having values 1 through S) and obtain a value ≥R on at least X out of Y rolls. Betty has a variety of dice with different numbers of sides S, and all her dice are fair (for a g

2021-03-04 15:08:35 239

原创 1125. 牛的旅行(flord)

1125. 牛的旅行(flord)#include <bits/stdc++.h>#define inf 0x3f3f3f3fusing namespace std;typedef long long LL;const int N = 1e3 + 10;#define x first#define y second#define inf 1e9pair<double, double> s[N];double ma[N][N], d[N], ans1 = 0, an

2021-03-04 14:37:52 311 1

原创 383. 观光(求最短路和次短路的次数)

观光求最短路和次短路的次数spfa算法不存在拓扑序,这里不能使用#include <bits/stdc++.h>#define inf 0x3f3f3f3fusing namespace std;typedef long long LL;const int N = 1e6 + 10;int n, m, t, x, y, w, k;int h[N], cnt = 0;int ans[2][N], d[2][N];struct node { int y, w, .

2021-03-03 20:57:03 140 1

原创 1134. 最短路计数

最短路计数给出一个 N 个顶点 M 条边的无向无权图,顶点编号为 1 到 N。问从顶点 1 开始,到其他每个点的最短路有几条。输入格式第一行包含 2 个正整数 N,M,为图的顶点数与边数。接下来 M 行,每行两个正整数 x,y,表示有一条顶点 x 连向顶点 y 的边,请注意可能有自环与重边。输出格式输出 N 行,每行一个非负整数,第 i 行输出从顶点 1 到顶点 i 有多少条不同的最短路,由于答案有可能会很大,你只需要输出对 100003 取模后的结果即可。如果无法到达顶点 i 则输出.

2021-03-02 16:57:25 115

原创 341. 最优贸易 (最短路)

最优贸易C国有 n 个大城市和 m 条道路,每条道路连接这 n 个城市中的某两个城市。任意两个城市之间最多只有一条道路直接相连。这 m 条道路中有一部分为单向通行的道路,一部分为双向通行的道路,双向通行的道路在统计条数时也计为1条。C国幅员辽阔,各地的资源分布情况各不相同,这就导致了同一种商品在不同城市的价格不一定相同。但是,同一种商品在同一个城市的买入价和卖出价始终是相同的。商人阿龙来到C国旅游。当他得知“同一种商品在不同城市的价格可能会不同”这一信息之后,便决定在旅游的同时,利用商品在.

2021-03-01 19:34:28 88

原创 Laying Cables (单调栈)

One-dimensional country has n cities, the i-th of which is located at the point xi and has population pi, and all xi, as well as all pi, are distinct. When one-dimensional country got the Internet, it was decided to place the main server in the largest cit

2021-02-24 08:04:28 68

原创 Two Points(三分求极值)

There are two points (x1, y1) and (x2, y2) on the plane. They move with the velocities (vx1, vy1) and (vx2, vy2). Find the minimal distance between them ever in future.InputThe first line contains four space-separated integers x1, y1, x2, y2 ( - 104 ≤ x1

2021-02-24 07:58:03 227

原创 Maximum Palindromes (逆元,排列组合)

题目链接利用前缀和求出对应区间每个字母的个数要求排列组合数为,字母总数的阶乘 除以 每个字母数目的阶乘的乘积,若有字母数目个数为奇数,再乘以数目为奇数的字母个数将除以得到乘积,转变为乘以该数取模mod的逆元根据结论:若b,m互质,则b模m的乘法逆元为 b^(m-2)再利用快速幂求出乘法逆元#include <bits/stdc++.h>using namespace std;typedef long long LL;const LL N = 2e5 + 10;const

2021-02-18 12:38:03 156

原创 197. 阶乘分解(数学)

阶乘分解给定整数 N ,试把阶乘 N! 分解质因数,按照算术基本定理的形式输出分解结果中的 pi 和 ci 即可。输入格式一个整数N。输出格式N! 分解质因数后的结果,共若干行,每行一对pi,ci,表示含有pcii项。按照pi从小到大的顺序输出。数据范围1≤N≤106输入样例:5输出样例:2 33 15 1样例解释5!=120=23∗3∗5#include <bits/stdc++.h>using namespace std;const int N = 1e6

2021-02-01 19:16:56 299

原创 Concerts (DP)

ConcertsJohn enjoys listening to several bands, which we shall denote using A through Z. Hewants to attend several concerts, so he sets out to learn their schedule for the upcoming season.He finds that in each of the following n days (n ≤ 104), there i

2021-01-29 09:28:19 118

原创 可达性统计(拓扑排序+bitset)

给定一张N个点M条边的有向无环图,分别统计从每个点出发能够到达的点的数量。输入格式第一行两个整数N,M,接下来M行每行两个整数x,y,表示从x到y的一条有向边。输出格式输出共N行,表示每个点能够到达的点的数量。数据范围1≤N,M≤30000输入样例:10 103 82 32 55 95 92 33 94 82 104 9输出样例:1633211111#include <bits/stdc++.h>using namespace std

2021-01-27 11:20:47 125

原创 Convoy (二分)

You and your friends have gathered at your house to prepare for the Big Game, which you all plan to attend in the afternoon at the football stadium across town. The problem: you only have k cars between you, with each car seating five people (including the

2021-01-27 10:23:22 169

原创 Perfect Ban

Constantine and Mike are playing the board game «Wrath of Elves». There are n races and m classes of characters in this game. Each character is described by his race and class. For each race and each class there is exactly one character of this race and th

2021-01-20 09:25:10 75

原创 No More Inversions (规律)

C. No More Inversionstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have a sequence a with n elements 1,2,3,…,k−1,k,k−1,k−2,…,k−(n−k) (k≤n<2k).Let’s call as inversion in a a pair of indice

2021-01-15 12:08:00 751

原创 蛇形矩阵

输入两个整数n和m,输出一个n行m列的矩阵,将数字 1 到 n*m 按照回字蛇形填充至矩阵中。具体矩阵形式可参考样例。输入格式输入共一行,包含两个整数n和m。输出格式输出满足要求的矩阵。矩阵占n行,每行包含m个空格隔开的整数。数据范围1≤n,m≤100输入样例:3 3输出样例:1 2 38 9 47 6 5#include <bits/stdc++.h>using namespace std;int a[105][105];int main() { i

2021-01-14 22:24:49 81

原创 最长回文 (Manacher 算法)

给出一个只由小写英文字符a,b,c…y,z组成的字符串S,求S中最长回文串的长度.回文就是正反读都是一样的字符串,如aba, abba等Input输入有多组case,不超过120组,每组输入为一行小写英文字符a,b,c…y,z组成的字符串S两组case之间由空行隔开(该空行不用处理)字符串长度len <= 110000Output每一行一个整数x,对应一组case,表示该组case的字符串中所包含的最长回文长度.Sample InputaaaaababSample Output

2021-01-14 19:27:31 115

原创 The Feast and the Bus (暴力)

Employees of JebTrains are on their way to celebrate the 256-th day of the year! There are n employees and k teams in JebTrains. Each employee is a member of some (exactly one) team. All teams are numbered from 1 to k. You are given an array of numbers t1,

2021-01-11 17:01:54 131

原创 The Parade (二分)

The Berland Army is preparing for a large military parade. It is already decided that the soldiers participating in it will be divided into k rows, and all rows will contain the same number of soldiers.Of course, not every arrangement of soldiers into k r

2021-01-11 17:00:13 124

原创 Nine Packsa (01背包)

Nine Packs“It’s like how hot dogs come in packs of ten, and buns come in packs of eight or twelve — you have to buy nine packs to make it come out even.”This is a quote from the 1986 movie, “True Stories”, and it’s true; well, almost true. You could buy

2021-01-03 20:35:03 243

原创 数据结构实验:哈希表

J - 数据结构实验:哈希表Description在n个数中,找出出现次数最多那个数字,并且输出出现的次数。如果有多个结果,输出数字最小的那一个。Input单组数据,第一行数字n(1<=n<=100000)。接下来有n个数字,每个数字不超过100000000Output出现次数最多的数字和次数。SampleInput31 1 2Output1 2#include <bits/stdc++.h>using namespace std;const int

2020-12-25 17:44:39 135

原创 H - 二分练习

H - 二分练习Description给你一个序列,然后给你m个元素,让你从序列中找出与每个元素最接近的数字输出来,如果有两个就输出两个。Input多组输入,第一行给你两个数n(0 < n < 10000000),m(0 < m < n),接下来是数列的n个数,然后再输入m个元素,让你找出最接近每个元素的值。如果有两个,按从小到大输出。Output这m个数分别输出最接近每个元素的值,组与组之间输出一个空行。SampleInput8 41 2 3 4 5 6 8 1

2020-12-25 17:15:53 83

原创 数据结构实验之查找三:树的种类统计 (排序树)

C - 数据结构实验之查找三:树的种类统计Description随着卫星成像技术的应用,自然资源研究机构可以识别每一个棵树的种类。请编写程序帮助研究人员统计每种树的数量,计算每种树占总数的百分比。Input输入一组测试数据。数据的第1行给出一个正整数N (n <= 100000),N表示树的数量;随后N行,每行给出卫星观测到的一棵树的种类名称,树的名称是一个不超过20个字符的字符串,字符串由英文字母和空格组成,不区分大小写。Output按字典序输出各种树的种类名称和它占的百分比,中间以空格

2020-12-25 16:19:11 99

原创 C - 佑子的难题

C - 佑子的难题Description有一天,佑子在杂志上找到了一个有趣的问题:有一个数 n,在一步中,可以将这个数乘 2,或是除以 6(如果这个数可以被 6 整除)使数 n 变为 1 所需的最小操作数是多少。佑子找到了麻衣,想要在这个问题上一决高下,先解出这个问题的人获胜。由于众所周知的原因,佑子无法在任何比赛中赢过麻衣,但佑子也不是输了就放弃的类型。所以麻衣为了尽早结束这地狱般的比赛,找到了热爱编程的你,并希望你帮助佑子快速解出这个问题的答案。Input第一行包含一个整数T,表示有T组数

2020-12-22 10:10:10 134

原创 G - 这么短的题面一定不会很难吧 (贪心)

G - 这么短的题面一定不会很难吧Description你有一个整数 nn 和 ss 。一步中你可以使 nn 增加 11(n= n+1n=n+1)。找到最小步数使得 nn 的每一位加起来小于或等于 ss。Input第一行包含一个整数 tt (1\le t\le 2·10^41≤t≤2⋅104)——测试数据组数。随后有t组测试数据每组测试数据包含两个整数 nn 和 ss (1\le n\le 10^{15};1\le s \le 162)(1≤n≤1015;1≤s≤162)。Output

2020-12-21 19:32:07 122

空空如也

空空如也

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

TA关注的人

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