自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

代码笔记本

个人博客www.yyycode.cn

  • 博客(85)
  • 收藏
  • 关注

原创 C. Magic Grid

https://codeforces.com/problemset/problem/1208/CLet us define amagicgrid to be a square matrix of integers of sizen×nn×n, satisfying the following conditions.All integers from00to(n2−1)(n2−1)inclusive appear in the matrixexactly once. Bitwise ...

2020-08-31 22:48:52 336

原创 D. Christmas Trees

https://codeforces.com/problemset/problem/1283/D题目描述There arennChristmas trees on an infinite number line. Theii-th tree grows at the positionx_ixi​. Allx_ixi​are guaranteed to be distinct.Each integer point can be either occupied by the Chri...

2020-08-31 21:32:18 263

原创 Beautiful Numbers

https://codeforces.com/problemset/problem/300/C题目描述Vitaly is a very weird man. He's got two favorite digitsaaandbb. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digitsaaandbb. Vitaly calls a ...

2020-08-31 20:17:36 251

原创 D. Vasya and Triangle(数论)

https://codeforces.com/problemset/problem/1030/D题目描述Vasya has got three integersnn,mmandkk. He'd like to find three integer points(x_1, y_1)(x1​,y1​),(x_2, y_2)(x2​,y2​),(x_3, y_3)(x3​,y3​), such that0 \le x_1, x_2, x_3 \le n0≤x1​,x2​,x3​≤...

2020-08-31 17:28:39 211

原创 B. Tokitsukaze, CSL and Stone Game

https://codeforces.com/problemset/problem/1190/B展开题目描述Tokitsukaze and CSL are playing a little game of stones.In the beginning, there arennpiles of stones, theii-th pile of which hasa_iai​stones. The two players take turns making moves. Toki...

2020-08-31 14:32:17 240

原创 B. Power Sequence

https://codeforces.com/contest/1397/problem/BLet's call a list of positive integersa0,a1,...,an−1a0,a1,...,an−1apower sequenceif there is a positive integercc, so that for every0≤i≤n−10≤i≤n−1thenai=ciai=ci.Given a list ofnnpositive integersa...

2020-08-31 12:05:29 1109

原创 Stoned Game

https://codeforces.com/contest/1397/problem/DT is playing a game with his friend, HL.There arennpiles of stones, theii-th pile initially hasaiaistones.T and HL will take alternating turns, with T going first. In each turn, a player chooses a non...

2020-08-31 11:59:01 353

原创 Multiples of Length

https://codeforces.com/contest/1397/problem/CYou are given an arrayaaofnnintegers.You want to make all elements ofaaequal to zero by doing the following operationexactly threetimes:Select a segment, for each number in this segment we can add ...

2020-08-31 11:55:13 460

原创 A. Juggling Letters

https://codeforces.com/contest/1397/problem/A思路:map模拟一下看每个字母能不能平均分配就好了#include<iostream>#include<vector>#include<queue>#include<cstring>#include<cmath>#include<map>#include<set>#include<cstdio>

2020-08-31 11:52:47 227

原创 Little Elephant and Array(前缀和)

https://codeforces.com/problemset/problem/220/B展开题目描述The Little Elephant loves playing with arrays. He has arrayaa, consisting ofnnpositive integers, indexed from 1 tonn. Let's denote the number with indexiiasa_{i}ai​.Additionally the Li...

2020-08-30 21:52:48 173

原创 Paint the Tree(链dfs)

题目描述You are given a tree consisting ofnnvertices. A tree is an undirected connected acyclic graph.Example of a tree.You have to paint each vertex into one of three colors. For each vertex, you know the cost of painting it in every color.You have to..

2020-08-30 20:35:16 267

原创 P5490 【模板】扫描线

关于理解扫描线的几个不错的博客:https://www.luogu.com.cn/blog/paperghost/ls-xue-xi-bi-ji-note37-sao-miao-xian-line-sweep-algorithmhttps://blog.csdn.net/sslz_fsy/article/details/82902644板子:#include<iostream>#include<vector>#include<queue>#incl

2020-08-30 18:47:52 262

原创 牛牛的算术(公式推导)

链接:https://ac.nowcoder.com/acm/contest/7079/B来源:牛客网时间限制:C/C++ 2秒,其他语言4秒空间限制:C/C++ 524288K,其他语言1048576K64bit IO Format: %lld题目描述牛牛最近学习了取模是什么 于是他看到了下面这一道题:多次询问:每次询问包含一个正整数 nnn要求你输出下列结果∏i=1n∑j=1i∑k=1ji×j×k\prod_{i=1}^n \sum_{j=1}^i \sum_{k=1}^j ..

2020-08-29 23:37:20 4084 1

原创 牛牛的mex(思维-前后缀最小值)

链接:https://ac.nowcoder.com/acm/contest/7079/A来源:牛客网牛牛的mex时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 524288K,其他语言1048576K64bit IO Format: %lld题目描述牛牛现在有一个长度为nnn 的序列 a1,a2,…,ana_1,a_2,\ldots,a_na1​,a2​,…,an​。现在牛牛有qqq 次询问,每次想询问区间[l,r][l,r][l,r] 的 mex 是什么。...

2020-08-29 23:32:28 1246

原创 Number(bfs)

Description小沃沃在研究数字。小沃沃初始有nn个数字,第ii个数字为a_iai​。每次操作,小沃沃可以选择一个数字xx,把它修改为x^2x2或者\lfloor \sqrt{x} \rfloor⌊x​⌋。请问小沃沃最少需要操作几次,才能让所有数字都相等?Input第一行一个整数n~(1 \leq n \leq 100000)n(1≤n≤100000)。接下来一行nn个整数,第ii个整数为a_i~(1\leq a_i \leq 100000)...

2020-08-29 23:26:24 139

原创 D. Maximum Distributed Tree(贪心+树dfs)

https://codeforces.com/problemset/problem/1401/D题目描述You are given a tree that consists ofnnnodes. You should label each of itsn-1n−1edges with an integer in such way that satisfies the following conditions:each integer must be greater than00; ...

2020-08-29 16:32:10 421

原创 D. Good Substrings(双模数哈希)

https://codeforces.com/problemset/problem/271/DYou've got strings, consisting of small English letters. Some of the English letters aregood, the rest arebad.A substrings[l...r](1 ≤ l ≤ r ≤ |s|) of strings  =  s1s2...s|s|(where|s|is the len...

2020-08-29 15:20:36 696

原创 Vasiliy‘s Multiset(字典树)

https://www.luogu.com.cn/problem/CF706Dhttps://codeforces.com/problemset/problem/706/D题目描述Author has gone out of the stories about Vasiliy, so here is just a formal task description.You are givenqqqueries and a multisetAA, initially containing ...

2020-08-29 15:17:15 258

原创 P2341 [USACO03FALL][HAOI2006]受欢迎的牛 G(缩点)

https://www.luogu.com.cn/problem/P2341题目背景本题测试数据已修复。题目描述每头奶牛都梦想成为牛棚里的明星。被所有奶牛喜欢的奶牛就是一头明星奶牛。所有奶牛都是自恋狂,每头奶牛总是喜欢自己的。奶牛之间的“喜欢”是可以传递的——如果AA喜欢BB,BB喜欢CC,那么AA也喜欢CC。牛栏里共有NN头奶牛,给定一些奶牛之间的爱慕关系,请你算出有多少头奶牛可以当明星。输入格式第一行:两个用空格分开的整数:NN和MM。接下来MM行...

2020-08-24 14:58:06 311

原创 Reachability from the Capital(缩点)

There arenncities andmmroads in Berland. Each road connects a pair of cities. The roads in Berland are one-way.What is the minimum number of new roads that need to be built to make all the cities reachable from the capital?New roads will also be on...

2020-08-24 14:55:13 250

原创 D Pashmak and Parmida‘s problem(树状数组求逆序对)

https://codeforces.com/problemset/problem/459/DParmida is a clever girl and she wants to participate in Olympiads this year. Of course she wants her partner to be clever too (although he's not)! Parmida has prepared the following test problem for Pashmak

2020-08-24 14:46:51 334

原创 P1908 逆序对

题目描述猫猫 TOM 和小老鼠 JERRY 最近又较量上了,但是毕竟都是成年人,他们已经不喜欢再玩那种你追我赶的游戏,现在他们喜欢玩统计。最近,TOM 老猫查阅到一个人类称之为“逆序对”的东西,这东西是这样定义的:对于给定的一段正整数序列,逆序对就是序列中a_i>a_jai​>aj​且i<ji<j的有序对。知道这概念后,他们就比赛谁先算出给定的一段正整数序列中逆序对的数目。注意序列中可能有重复数字。Update:数据已加强。输入格式第一行,一个数nn,表...

2020-08-24 14:41:11 702

原创 P3386 【模板】二分图最大匹配

https://www.luogu.com.cn/problem/P3386题目描述给定一个二分图,其左部点的个数为nn,右部点的个数为mm,边数为ee,求其最大匹配的边数。左部点从11至nn编号,右部点从11至mm编号。输入格式输入的第一行是三个整数,分别代表nn,mm和ee。接下来ee行,每行两个整数u, vu,v,表示存在一条连接左部点uu和右部点vv的边。输出格式输出一行一个整数,代表二分图最大匹配的边数。输入输出样例...

2020-08-21 15:38:46 255

原创 D. Slime(思维,符号放置)

D. Slimetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere arennslimes in a row. Each slime has an integer value (possibly negative or zero) associated with it.Any slime can eat..

2020-08-21 14:59:46 574

原创 A. Garland(线性dp)

https://codeforces.com/problemset/problem/1286/A// cin.tie(0);std::ios::sync_with_stdio(false);// LL n;cin>>n;// for(LL i=1;i<=n;i++){// cin>>a[i];// }// memset(dp,0x3f,sizeof(dp));// dp[1][1]=dp[1][0]=0;// for(LL i=2;i&lt

2020-08-20 22:24:26 308

原创 D. Dima and Lisa(数论-哥德巴赫猜想)

https://codeforces.com/problemset/problem/584/DDima loves representing an odd number as the sum of multiple primes, and Lisa loves it when there are at most three primes. Help them to represent the given number as the sum of at most than three primes.M

2020-08-20 19:01:34 272

原创 B. Edge Weight Assignment

https://codeforces.com/problemset/problem/1338/BYou have unweighted tree ofnnvertices. You have to assign apositiveweight to each edge so that the following condition would hold:For every two different leavesv1v1andv2v2of this tree,bitwise XOR...

2020-08-20 16:02:14 393

原创 E. Count The Blocks

https://codeforces.com/problemset/problem/1327/EYou wrote down all integers from00to10n−110n−1, padding them with leading zeroes so their lengths are exactlynn. For example, ifn=3n=3then you wrote out000,001, ...,998,999.A block in an integer...

2020-08-20 13:47:37 199

原创 D. Distance in Tree

https://codeforces.com/problemset/problem/161/DAtreeis a connected graph that doesn't contain any cycles.Thedistancebetween two vertices of a tree is the length (in edges) of the shortest path between these vertices.You are given a tree withnve...

2020-08-20 09:58:41 291

原创 D. Multiplication Table

https://codeforces.com/problemset/problem/448/DBizon the Champion isn't just charming, he also is very smart.While some of us were learning the multiplication table, Bizon the Champion had fun in his own manner. Bizon the Champion painted ann × mmult..

2020-08-19 20:56:42 649

原创 younik去吃午饭啦

链接:https://ac.nowcoder.com/acm/contest/7031/E来源:牛客网题目描述 做完了检查之后,younik得知得要星期天才能拿到结果,于是她离开了校医院。她抬头看了看太阳,感觉自己实在是枵肠辘辘,饥不可堪。Younik早就听说陕西师范大学又叫陕西吃饭大学,她决定去陕师大食堂填饱肚子。Younik走到食堂旁边,发现食堂门口居然也在排队(今天怎么到处都在排队),她上前一问,原来为了方便管理,食堂决定,每一个小时才允许大家进去一次,...

2020-08-17 13:22:44 188

原创 新冠病毒要回家

链接:https://ac.nowcoder.com/acm/contest/7031/F来源:牛客网题目描述新冠病毒被医生从患者的身体中赶了出来,它很伤心,原本一切都是那么的快乐,它和它的孩子们快乐地生活在一起。但是这里的抗疫力度太强了,被赶出来后,由于人们都带了口罩,它没办法再次回到之前那样的舒适环境。现在它想要离开医院回家。它有很多条路可以离开医院,虽然它想要尽可能快的回去,但是它还想看看路上的其它病毒过得怎么样,也好顺便带它们一起离开,于是它决定走第二短的路回去。医院总有 V (0 .

2020-08-16 21:26:30 428

原创 younik要排号

链接:https://ac.nowcoder.com/acm/contest/7031/D来源:牛客网题目描述Younik挂好号之后,就去找医生了。但是她没想到,看医生居然也要排队!于是younik可怜兮兮地站在大厅里,盯着墙上的显示屏,显示屏会不停地打出名字,如果一个人被叫到但没进去,显示屏可能会叫他很多次。你能告诉younik她是第几个被叫到的人吗? Ps.如果一个人被叫了两次,他还是一个人,不能算两个人。(题目数据范围为200)输入描述:第一行是一个正整数n,表示显示.

2020-08-16 21:23:34 473

原创 younik吃大餐

链接:https://ac.nowcoder.com/acm/contest/7031/G来源:牛客网题目描述Younik的检查结果出来了,核酸检测为阴性,她非常高兴,立刻决定去饭店大吃一顿。到了饭店,Younik看到琳琅满目的菜单,开始犯了选择困难症。这时作为顶级吃货的你恰好坐到了Younik的旁桌,你决定发扬一下雷锋精神,帮助Younik决定吃哪些菜。假设每一道菜都有相应的快乐值,Younik每吃一道菜就会获得相应的快乐值,这里有N道菜,每道菜可以吃多次,但是同一道菜每重复吃一次,得到的.

2020-08-16 21:17:04 186

原创 younik要挂号

链接:https://ac.nowcoder.com/acm/contest/7031/C来源:牛客网题目描述younik来到校医院之后打算挂号,校医院最近出台了一个新的挂号制度。医院里有n个专家,专家有一定的挂号费用且挂号费用是一个从1到m的整数,younik别出心裁,打算选择n个专家进行挂号,并把这n个专家的挂号费用排成一个序列a。求满足下列条件的长度为n的序列a的个数1.该序列包含n个专家的挂号费用;2.对于每一个序列,有且仅有一对相同的元素;3.对于每一个序列,存在一个...

2020-08-16 21:10:07 267

原创 组合数板子

typedef long long ll;using namespace std;const int MAXN=2e5+50;const int inf=0x3f3f3f3f;const int M=5000*4;const int mod=998244353;ll fac[MAXN];ll quick(ll a,ll b){ ll ans=1; while(b){ if(b&1)ans=ans*a%mod; a=a*a%mod; .

2020-08-16 21:06:11 274

原创 P2740 [USACO4.2]草地排水Drainage Ditches

题目背景在农夫约翰的农场上,每逢下雨,贝茜最喜欢的三叶草地就积聚了一潭水。这意味着草地被水淹没了,并且小草要继续生长还要花相当长一段时间。因此,农夫约翰修建了一套排水系统来使贝茜的草地免除被大水淹没的烦恼(不用担心,雨水会流向附近的一条小溪)。作为一名一流的技师,农夫约翰已经在每条排水沟的一端安上了控制器,这样他可以控制流入排水沟的水流量。题目描述农夫约翰知道每一条排水沟每分钟可以流过的水量,和排水系统的准确布局(起点为水潭而终点为小溪的一张网)。需要注意的是,有些时候从一处到另一处不只有一条排

2020-08-09 20:50:05 193

原创 P3376 【模板】网络最大流

最大流EK板子对板子的一个小优化。取edge的时候多加一个const.从洛谷的500ms吸氧气加到260ms#include<iostream>#include<vector>#include<queue>#include<cstring>#include<cmath>#include<map>#include<cstdio>#include<algorithm>#define debu

2020-08-09 20:49:31 121

原创 CF1129A2 Toy Train

当一个车站如果有最多的糖果数x,那么跑x-1圈就能让前面x-1个糖果放到相应的地方,如果想让这时候跑的站数最少,那么最后一个应该放最近的糖果。如果当前这个车站a并不是最多的糖果数,但是要跑的最少站数取决于拥有最多糖果数的站点b。(只有最多糖果数的站点跑完了才能全部跑完)所以我们先让a到b就可以了。(也就是加上a-b的距离)最后我们枚举每个车站作为起始点,再枚举这个车站到另一个车站的距离,最后每次取最大输出#include<iostream>#include<vector

2020-08-09 12:24:25 186

原创 C. Journey

CodeForces – 839CThere arencities andn - 1roads in the Seven Kingdoms, each road connects two cities and we can reach any city from any other by the roads.Theon and Yara Greyjoy are on a horse in the first city, they are starting traveling through...

2020-08-08 23:36:06 287

空空如也

空空如也

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

TA关注的人

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