自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(105)
  • 问答 (2)
  • 收藏
  • 关注

原创 C. Strange Test(位运算)

Igor is in 11th grade. Tomorrow he will have to write an informatics test by the strictest teacher in the school, Pavel Denisovich.Igor knows how the test will be conducted: first of all, the teacher will give each student two positive integers aa and bb (

2024-06-14 10:34:43 705 1

原创 F. Yet Another Problem About Pairs Satisfying an Inequality(二分搜索)

You are given an array a1,a2,…ana1,a2,…an. Count the number of pairs of indices 1≤i,j≤n1≤i,j≤n such that ai<i<aj<jai<i<aj<j.InputThe first line contains an integer tt (1≤t≤10001≤t≤1000) — the number of test cases.The first line of each test case contains a

2024-06-14 10:32:22 1067

原创 D. Yet Another Minimization Problem(dp,数学公式推导)

You are given two arrays aa and bb, both of length nn.You can perform the following operation any number of times (possibly zero): select an index ii (1≤i≤n1≤i≤n) and swap aiai and bibi.Let's define the cost of the array aa as ∑ni=1∑nj=i+1(ai+aj)2∑i=1n∑j=i

2024-06-13 19:12:05 1151

原创 璨与序列 题解(stl,dfs)

璨有一个长度为n的整数序列a1​,a2​,…,an​。不过他想重新排序这个序列(也可以保持原序列),把这个序列变成每个元素ai​(2≤i≤n)都恰好是前一个元素的二倍或前一个元素的三分之一。

2024-06-13 19:10:22 431

原创 C. Rooks Defenders(树状数组)

InputOutputExampleinputCopy8 101 2 43 6 2 7 21 3 23 6 2 7 21 4 33 2 6 4 82 4 33 2 6 4 81 4 83 2 6 4 8outputCopyNoYesYesNoYesNote正在上传…重新上传取消正在上传…重新上传取消正在上传…重新上传取消正在上传…重新上传取消正在上传…重新上传取消正在上传…重新上传取消。

2024-06-12 10:31:49 905

原创 飞行路线(dijkstra)(分层图)

该航空公司一共在n个城市设有业务,设这些城市分别标记为0到n-1,一共有m种航线,每种航线连接两个城市,并且航线有一定的价格。接下来有m行,每行三个整数,a,b,c,表示存在一种航线,能从城市a到达城市b,或从城市b到达城市a,价格为c。对于100%的数据,2

2024-06-12 10:28:56 463

原创 L2-3 完全二叉树的层序遍历 (25 分)

一个二叉树,如果每一个层的结点数都达到最大值,则这个二叉树就是。对于深度为 D 的,有 N 个结点的二叉树,若其结点对应于相同深度完美二叉树的层序遍历的前 N 个结点,这样的树就是。给定一棵完全二叉树的后序遍历,请你给出这棵树的层序遍历结果。

2024-06-12 10:27:45 328

原创 Fillomino 2(dfs,联通块,思维)

InputOutputExamplesinputCopy32 3 1outputCopy22 33 3 1inputCopy51 2 3 4 5outputCopy12 23 3 34 4 4 45 5 5 5 5Note正在上传…重新上传取消。

2024-06-11 09:09:41 1033

原创 New Year and Permutation(排列组合,公式推导)

Recall that the permutation is an array consisting of nn distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array) and [1,3,4] is also not a permutation (n=3

2024-06-11 09:08:31 588

原创 Berland Regional(前缀和,分块,莫队)

Polycarp is an organizer of a Berland ICPC regional event. There are nn universities in Berland numbered from 11 to nn. Polycarp knows all competitive programmers in the region. There are nn students: the ii-th student is enrolled at a university uiui and

2024-06-10 11:15:14 859

原创 Connect cf题解(dfs,bfs,暴力)

转存失败重新上传取消An example planet with n=5n=5. It also appears in the first sample test.InputOutputExamplesinputCopy51 15 50000111111001110011000110outputCopy10inputCopy31 33 1010101010outputCopy8Note。

2024-06-10 11:13:07 861

原创 牛客多校Ancestor(lca,集合的lca)

2,用两棵树存各自的前缀后缀lca,然后调用即可。1,lca的板子题稍微进阶点,

2024-06-09 21:31:28 791

原创 Rating Compression(单调栈,树状数组)

On the competitive programming platform CodeCook, every person has a rating graph described by an array of integers aa of length nn. You are now updating the infrastructure, so you've created a program to compress these graphs.The program works as follows.

2024-06-09 21:30:55 908

原创 Timofey and a tree(思维题)

Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci.Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timo

2024-03-31 10:04:13 602

原创 python项目总结(持续更新中)

【代码】python项目总结(持续更新中)

2024-03-31 10:03:02 632

原创 Anton and Making Potions(枚举,二分)

Anton is playing a very interesting computer game, but now he is stuck at one of the levels. To pass to the next level he has to prepare n potions.Anton has a special kettle, that can prepare one potions in x seconds. Also, he knows spells of two types tha

2024-03-25 18:50:20 749

原创 B. Party(思维)

A club plans to hold a party and will invite some of its nn members. The nn members are identified by the numbers 1,2,…,n1,2,…,n. If member ii is not invited, the party will gain an unhappiness value of aiai.There are mm pairs of friends among the nn membe

2024-03-24 21:56:49 762

原创 登山小分队(dfs,模拟)

接下来 n−1n-1n−1 行,每行两个整数,分别是 xi,yi(1≤xi,yi≤n)x_i,y_i(1 \le x_i,y_i \le n)xi​,yi​(1≤xi​,yi​≤n),表示有一条路连接 xix_ixi​ 号点 和 yiy_iyi​ 号点,其中 111 号点即为山顶,保证给定的图是一棵树。这个问题中,我们将山顶视作树的根节点,而山脚视为树的叶节点,上山的每一条路可以视作树的一条边。3,这个题最难的是,单个节点记录数量,dfs深度搜索,递归的书写。输出一行一个数,表示所有人都到齐的最少时间。

2024-03-24 21:52:24 479

原创 Array Destruction(枚举暴力,stl的合理选择)

You found a useless array aa of 2n2n positive integers. You have realized that you actually don't need this array, so you decided to throw out all elements of aa.It could have been an easy task, but it turned out that you should follow some rules:For examp

2024-03-23 14:17:51 603

原创 Pinkie Pie Eats Patty-cakes(贪心或者二分)

Pinkie Pie has bought a bag of patty-cakes with different fillings! But it appeared that not all patty-cakes differ from one another with filling. In other words, the bag contains some patty-cakes with the same filling.Pinkie Pie eats the patty-cakes one-b

2024-03-19 08:31:59 731

原创 Link with Monotonic Subsequence(分块,思维)

2,3 2 1 6 5 4 9 8 7,这样的话,分sqrt(n)块,块内减,块间递增,value是sqrt(n)。1,打表,找到符合题意的解,发现value和sqrt(n)有关。

2024-03-18 08:36:33 929

原创 Zigzags(思维,前缀处理)

You are given an array a1,a2…ana1,a2…an. Calculate the number of tuples (i,j,k,l)(i,j,k,l) such that:InputThe first line contains a single integer tt (1≤t≤1001≤t≤100) — the number of test cases.The first line of each test case contains a single integer nn

2024-03-17 20:05:25 565

原创 Navigation System(djkstra,反向建图,思维)

The map of Bertown can be represented as a set of nn intersections, numbered from 11 to nn and connected by mm one-way roads. It is possible to move along the roads from any intersection to any other intersection. The length of some path from one intersect

2024-03-17 18:28:30 2257

原创 Link with Arithmetic Progression(最小二乘法,三分)

1,用long double ,这里面精度要求较高,用double是不行的。2,要用read()快读,首项是a+b。我用的最小二乘法求回归方程,

2024-03-16 15:19:55 960

原创 The Sports Festival(区间dp)

The student council is preparing for the relay race at the sports festival.The council consists of nn members. They will run one after the other in the race, the speed of member ii is sisi. The discrepancy didi of the ii-th stage is the difference between

2024-03-16 08:46:49 777

原创 Divide and Summarize(二分,递归,前缀和)

正在上传…重新上传取消InputOutputExampleinputCopy25 51 2 3 4 51891265 53 1 3 1 3123911outputCopyYesNoYesNoYesNoYesNoYesYesNote。

2024-03-15 18:00:49 995

原创 Eezie and Pie(树上差分)

题意:从i节点最多走d[i]长度,馅饼保鲜,一个节点一个节点地走,问每个节点经过的次数。

2024-03-15 10:07:04 837

原创 D. Peculiar Movie Preferences(思维,map)

InputOutputExampleinputCopy65zxabcczxba2abbad4codeforces3abc3abcdcba2ababoutputCopyYESNONOYESYESNONote。

2024-03-14 12:16:46 890

原创 Flood Fill(区间dp)

You are given a line of nn colored squares in a row, numbered from 11 to nn from left to right. The ii-th square initially has the color cici.Let's say, that two squares ii and jj belong to the same connected component if ci=cjci=cj, and ci=ckci=ck for all

2024-03-14 09:31:11 571

原创 G. Anna, Svyatoslav and Maps(最短路floyd,思维)

原题链接The main characters have been omitted to be short.You are given a directed unweighted graph without loops with nn vertexes and a path in it (that path is not necessary simple) given by a sequence p1,p2,…,pmp1,p2,…,pm of mm vertexes; for each 1≤i...

2024-03-13 10:52:26 875

原创 Bouncing Boomerangs(构造,思维,贪心)

正在上传…重新上传取消InputOutputExamplesinputCopy6outputCopy52 12 53 33 65 6inputCopy10outputCopy0inputCopy6outputCopy-1Note。

2024-03-12 20:40:48 813

原创 B2. Tokitsukaze and Good 01-String (hard version)(规律)

This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary stringssof lengthnn, consisting only of zeros and ones,nn...

2024-03-11 21:37:55 671

原创 L2-002 链表去重 (25 分)(数组模拟)(附链表相关)

给定一个带整数键值的链表 L,你需要把其中绝对值重复的键值结点删掉。即对每个键值 K,只有第一个绝对值等于 K 的结点被保留。同时,所有被删除的结点须被保存在另一个链表上。例如给定 L 为 21→-15→-15→-7→15,你需要输出去重后的链表 21→-15→-7,还有被删除的链表 -15→15。输入格式:输入在第一行给出 L 的第一个结点的地址和一个正整数 N(≤105,为结点总数)。一个结点的地址是非负的 5 位整数,空地址 NULL 用 −1 来表示。随后 N 行,每行按以下格式描述一个

2024-03-11 21:36:26 220

原创 Lorenzo Von Matterhorn(思维,二叉树,模拟)

iand 2iiand 2ii正在上传…重新上传取消qvuandwutovwdollars.vuInputq(1 ≤q≤ 1 000).The nextqvuwutovbywvuvu1 ≤vu≤ 1018,v≠u, 1 ≤wOutputExampleinputCopy71 3 4 301 4 1 21 3 6 82 4 31 6 1 402 3 72 2 4output。

2024-03-10 09:40:22 1046

原创 Integers Have Friends(线段树,双指针,GCD)

British mathematician John Littlewood once said about Indian mathematician Srinivasa Ramanujan that "every positive integer was one of his personal friends."It turns out that positive integers can also be friends with each other! You are given an array aa

2024-03-08 18:24:53 753 1

原创 Mocha and Railgun(几何规律)

来源:牛客网。

2024-03-08 18:23:08 909

原创 (牛客寒假训练)B-清楚姐姐学构造

2需要特判一下,不知道为什么2没有逆元,希望有大佬可以解释一下。在B题上,所有的东西都对了,就差一个知识点。

2023-01-30 22:24:40 207

原创 c++的左右对齐语句

c++的对齐语句

2022-12-28 16:18:19 399

原创 E. Counting Rectangles(二维前缀和)

原题链接You have nn rectangles, the ii-th rectangle has height hihi and width wiwi.You are asked qq queries of the form hs ws hb wbhs ws hb wb.For each query output, the total area of rectangles you own that can fit a rectangle of height hshs and width wsws wh

2022-09-23 21:33:05 554

原创 C. Connect the Points(计算几何)(找统一规律)

原题链接:You are given three points on a plane. You should choose some segments on the plane that are parallel to coordinate axes, so that all three points become connected. The total length of the chosen segments should be the minimal possible.Two points aa a

2022-09-22 19:58:36 280

空空如也

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

TA关注的人

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