自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

tomjobs的博客

I was so much older then, I'm younger than that now.

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

原创 About Me

Hello World

2020-08-07 00:08:05 1116 2

原创 超级码力在线编程大赛初赛一

那天是考试,随便打了一下,但是被编译器整吐了,输入的测试样例不能调,而且还不是题目给的样例。数组定义在class里面没初始化wa吐了,但是定义到外面也得初始化就玄学了。。。正三角形拼接思路:最多肯定只需要两次操作。但如果可以找出x与x*2,那么只需要一次操作。如果存在出现两次的数且这个数不是最大数,那么只需要一次操作。如果存在出现三次的数,那么不需要操作。class Solution {public: /** * @param lengths: the lengths o

2020-08-31 22:44:23 242

原创 Codeforces1397 D. Stoned Game(博弈)

T is playing a game with his friend, HL.There are ???? piles of stones, the ????-th pile initially has ???????? stones.T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single sto

2020-08-31 20:19:15 411

原创 Codeforces1397 C. Multiples of Length

You are given an array ???? of ???? integers.You want to make all elements of ???? equal to zero by doing the following operation exactly three times:Select a segment, for each number in this segment we can add a multiple of ???????????? to it, where ???

2020-08-31 19:31:07 250

原创 Codeforces1397 B. Power Sequence

Let’s call a list of positive integers ????0,????1,…,????????−1 a power sequence if there is a positive integer ????, so that for every 0≤????≤????−1 then ????????=????????.Given a list of ???? positive integers ????0,????1,…,????????−1, you are allowed t

2020-08-31 19:26:40 354

原创 Codeforces1397 A. Juggling Letters

You are given ???? strings ????1,????2,…,???????? consisting of lowercase Latin letters.In one operation you can remove a character from a string ???????? and insert it to an arbitrary position in a string ???????? (???? may be equal to ????). You may per

2020-08-31 19:20:08 506

原创 Codeforces1400 E. Clear the Multiset(分治)

You have a multiset containing several integers. Initially, it contains ????1 elements equal to 1, ????2 elements equal to 2, …, ???????? elements equal to ????.You may apply two types of operations:choose two integers ???? and ???? (????≤????), then rem

2020-08-31 19:17:44 280

原创 Codeforces1400 D. Zigzags

You are given an array ????1,????2…????????. Calculate the number of tuples (????,????,????,????) such that:1≤????<????<????<????≤????;????????=???????? and ????????=????????;InputThe first line contains a single integer ???? (1≤????≤100) — th

2020-08-31 19:11:32 219

原创 Codeforces1400 C. Binary String Reconstruction

Consider the following process. You have a binary string (a string where each character is either 0 or 1) ???? of length ???? and an integer ????. You build a new binary string ???? consisting of ???? characters. The ????-th character of ???? is chosen as

2020-08-31 19:06:47 181

原创 Codeforces1400 B. RPG Protagonist

You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course.You decided to rob a town’s blacksmith and you take a follower with you. You

2020-08-31 18:52:25 555

原创 Codeforces1400 A. String Similarity

A binary string is a string where each character is either 0 or 1. Two binary strings ???? and ???? of equal length are similar, if they have the same character in some position (there exists an integer ???? such that ????????=????????). For example:10010

2020-08-31 18:49:34 237 1

原创 Leetcode 第 203 场周赛

圆形赛道上经过次数最多的扇区class Solution {public: int a[105]; vector<int> mostVisited(int n, vector<int>& rounds) { memset(a,0,sizeof(a)); int now = rounds[0]; for(int i = 0;i < rounds.size();i++) { if.

2020-08-26 17:22:34 203

原创 Codeforces1388 D. Captain Flint and Treasure(贪心)

Captain Fint is involved in another treasure hunt, but have found only one strange problem. The problem may be connected to the treasure’s location or may not. That’s why captain Flint decided to leave the solving the problem to his crew and offered an abs

2020-08-17 00:44:27 247

原创 Codeforces 1388C. Uncle Bogdan and Country Happiness(构造)

Uncle Bogdan is in captain Flint’s crew for a long time and sometimes gets nostalgic for his homeland. Today he told you how his country introduced a happiness index.There are ???? cities and ????−1 undirected roads connecting pairs of cities. Citizens of

2020-08-17 00:39:05 287

原创 Codeforces1388 B. Captain Flint and a Long Voyage

Captain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. In such moments uncle Bogdan often remembers his nephew Denis. Today, he has told a story about how Denis helped him to come

2020-08-17 00:31:16 219

原创 Codeforces1388 A Captain Flint and Crew Recruitment

Despite his bad reputation, Captain Flint is a friendly person (at least, friendly to animals). Now Captain Flint is searching worthy sailors to join his new crew (solely for peaceful purposes). A sailor is considered as worthy if he can solve Flint’s task

2020-08-17 00:30:22 238

原创 2020百度之星初赛第二场 Solo(博弈DP)

Problem DescriptionAlice 和 Bob 准备 solo 一场算法竞赛。比赛一共有 nn 个题,编号为 1,2…,n1,2…,n,对于第 ii 道题,Alice 需要 a[i]a[i] 分钟写出一份正确的代码,Bob 需要 b[i]b[i] 分钟写出一份正确的代码。比赛规则为每道题第一个通过的人积 1 分,如果两人同时 AC 该题,只有 Alice 得分。比赛时长为 10 ^ {18}1018分钟。Alice 和 Bob 的比赛策略都满足:决定要去做某道题后,会一直解决该

2020-08-16 16:03:29 339

原创 Leetcode 第 202 场周赛

感觉就是拼手速的比赛,没什么意思,再打几次把排名打到前面就不打了。存在连续三个奇数的数组给你一个整数数组 arr,请你判断数组中是否存在连续三个元素都是奇数的情况:如果存在,请返回 true ;否则,返回 false 。class Solution {public: bool threeConsecutiveOdds(vector<int>& arr) { int len = arr.size(); for(int i = 0;i &l

2020-08-16 13:14:32 201

原创 XOR Tree AtCoder - apc001_f(链变点,状压)

题意:一棵树,每次可以将一个路径上所有边异或x。求最少多少次操作使得所有边为0。思路:和牛客多校那道题很像,都是将链转换到点。https://blog.csdn.net/tomjobs/article/details/107922058考虑链很难搞,想到要转换为考虑点。可以将一个点的点权设置为所有出边的异或值,这样每次修改一条链,相当于把链两边点点权异或x。结果等价于把所有点权变成0。所以可以算出所有点的点权,一开始的时候肯定将点权相同的点搞完。最后剩下的点点权都不同,这个过程可以状压DP.

2020-08-16 13:04:30 272

原创 Codeforces1398 E. Two Types of Spells(模拟,set)

Polycarp plays a computer game (yet again). In this game, he fights monsters using magic spells.There are two types of spells: fire spell of power ???? deals ???? damage to the monster, and lightning spell of power ???? deals ???? damage to the monster an

2020-08-15 11:12:01 401

原创 Codeforces 1398D. Colored Rectangles(DP)

You are given three multisets of pairs of colored sticks:???? pairs of red sticks, the first pair has length ????1, the second pair has length ????2, …, the ????-th pair has length ????????;???? pairs of green sticks, the first pair has length ????1, the

2020-08-15 11:01:13 3322 3

原创 Codeforces1398 C. Good Subarrays(map,前缀)

You are given an array ????1,????2,…,???????? consisting of integers from 0 to 9. A subarray ????????,????????+1,????????+2,…,????????−1,???????? is good if the sum of elements of this subarray is equal to the length of this subarray (∑????=???????????????

2020-08-15 10:52:11 483

原创 Codeforces1398 B.Substring Removal Game(博弈)

Alice and Bob play a game. They have a binary string ???? (a string such that each character in it is either 0 or 1). Alice moves first, then Bob, then Alice again, and so on.During their move, the player can choose any number (not less than one) of conse

2020-08-15 10:37:00 397

原创 Codeforces 1398 A Bad Triangle

You are given an array ????1,????2,…,????????, which is sorted in non-decreasing order (????????≤????????+1).Find three indices ????, ????, ???? such that 1≤????<????<????≤???? and it is impossible to construct a non-degenerate triangle (a triangle

2020-08-15 10:34:58 462

原创 牛客 最大最小(单调栈,区间最大大于最小两倍)

思路:首先必须明确单调栈的最主要的作用,就是找到每个数左边右边第一个小于大于他的数,如果配上倍增或者二分可以找到小于大于他的第k大数。所有用单调栈的题目都得思考怎么利用这个性质来套题目。对于本题,我们可以找到每个数右边第一个大于等于其两倍的数R2[i]R2[i]R2[i],小于等于其一半的数R3[i]R3[i]R3[i]。可以找到以每个数为左端点的可行区间的数目,也就是n−1−max(R2[i],R3[i])+1n-1-max(R2[i],R3[i])+1n−1−max(R2[i],R3[i])+.

2020-08-14 10:52:26 361

原创 CSUSTOJ 你真的会树套树套树吗?(平分背包,贪心)

你真的会树套树套树吗?Descriptiongaygay 黄和 gaygay 行在一次探险过程中,获得了 nn 颗宝石,第 ii 颗宝石有 a[i]a[i] 的价值。为了公平起见,他们决定要尽可能的使得他们 22 个人所获得的宝石价值尽可能的接近。但是他们有点懒,想让学弟学妹们帮帮他们,给他们一个分配方案。你能帮帮他们吗?Input第一行输入一个整数 nn , 2\leq n\leq 1e52≤n≤1e5,代表给定正整数的数量。第二行输入 nn 个正整数 a1,a2,a3…a1,a2,a3

2020-08-14 09:27:04 241

原创 CSUSTOJ 你真的会加法吗?(字典树)

你真的会加法吗?Description众所周知,LJ精通 1 + 11+1 和 1 + 21+2 , 这天他遇到一个简单的加法题,但这个加法有一个特殊的性质,它是不进位加法,比如当是10进制时 987 + 643 = 520987+643=520 ,当一位大于 1010 的时候我们我们对其模 1010 ,取余数作为这位的值,kk 进制数同理。现在给你 nn 个数 (1 \leq n \leq 1e5)(1≤n≤1e5),并且每个数最多只有 1010 位,然后给定一个 kk (2 \leq k \l

2020-08-14 09:27:00 266

原创 CSUSTOJ 你真的会泡面吗?(优先队列模拟)

思路:用两个优先队列模拟就好了#pragma GCC optimize(2)#include <cstdio>#include <cstring>#include <algorithm>#include <iostream>#include <map>#include <unordered_map>#include <vector>#include <queue>using namesp.

2020-08-14 09:26:56 204

原创 CSUSTOJ 你真的会字符串吗?(DP)

思路:最后结果每一位都等于s[i]s[i]s[i],只要知道当前位的pre[i]pre[i]pre[i]值和当前位的t[i]t[i]t[i]值就好了。所以定义dp[i][j]dp[i][j]dp[i][j]为到了第iii为,pre[i+1]=jpre[i+1]=jpre[i+1]=j的方案数。然后直接枚举当前位和当前pre[i]pre[i]pre[i]值就可以转移了。#pragma GCC optimize(2)#include <cstdio>#include <cstr.

2020-08-14 09:26:51 182

原创 CSUSTOJ 你真的会!(线段树)

思路:对于f(L,R)f(L,R)f(L,R),可以发现L=RL=RL=R时,f(L,R)=a[L]+1f(L,R)=a[L]+1f(L,R)=a[L]+1。否则等于f(L,K)∗f(K,R),L≤K≤Rf(L,K)*f(K,R),L≤K≤Rf(L,K)∗f(K,R),L≤K≤R。所以直接用线段树维护就好了。#include <cstdio>#include <cstring>#include <algorithm>using namespace std.

2020-08-14 09:26:46 243

原创 CSUSTOJ 你真的会图论吗?(三色三角形)

思路:就是三色三角形问题,直接容斥。算出每个点白色和黑色的边有多少个,那么可以算出每个点对应的非三色三角形个数。总数减掉非三色三角形个数即可。#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#include <vector>#include <queue>#include <iostream>#include &.

2020-08-14 09:26:40 428

原创 CSUSTOJ 你真的会数据结构吗?(质因数分解)

题意:a[i]a[i]a[i]最多只有30,对应10个素因子,仅考虑这些素因子即可。考虑题目的f(n)f(n)f(n),可以发现,f(n)=2cntf(n)=2^{cnt}f(n)=2cnt,cntcntcnt代表ddd的素因子个数,所以我们只需要维护每个数的素因子个数。相同素因子的数可以合并。所以完全不需要数据结构,直接用数组维护就好了。#include <cstdio>#include <cstring>#include <algorithm>#inc.

2020-08-14 09:26:34 230

原创 CSUST OJ 你真的会吃零食吗?(猴子分桃)

Description有nn个人分一堆零食,第一个人扔掉一包零食后刚好能均分成nn等份,然后他取走一份;第二个人再第一个人剩下零食的基础上做相同的操作,扔掉一包然后分成nn等份,然后取走一份;后面的人也这样做。问最少有多少个零食可以支持nn个人这样分配。每个人必须都有零食拿到手。Input输入一行一个整数n(2\le n\le 9)n(2≤n≤9).Output一行一个整数表示答案。Sample Input 12Sample Output 17Hint首先有7包零食,扔掉1包还剩6

2020-08-13 21:25:47 247

原创 杭电多校第八场 Hexagon(规律)

题意:在半径为n的蜂窝图里面走,要求走过的点不能再走,输出路径,且相邻两个路径方向要尽量不同。思路:每次走边上两层。(直接拿了王老板的图)#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#include <vector>#include <queue>#include <iostream>#include

2020-08-13 21:23:33 321

原创 杭电多校第八场 Fluctuation Limit(区间交)

Problem DescriptionIt is preferrable to read the pdf statment.Cuber QQ has signed up for a gambling game, that challenges him to predict the stock price of Quber CC Limited, for the next following n days. He shall make his prediction by filling a table w

2020-08-13 21:20:19 207

原创 杭电多校第八场 Clockwise or Counterclockwise(向量叉乘)

Problem DescriptionIt is preferrable to read the pdf statment.After some basic geometric lessons, Cuber QQ has learned that one can draw one and only one circle across three given distinct points, on a 2D plane. Specialized in art, Cuber QQ has shown rem

2020-08-13 21:14:14 268

原创 杭电多校第八场 Isomorphic Strings(最小表示法,循环同构)

Problem DescriptionIt is preferrable to read the pdf statment.Two strings are called cyclical isomorphic if one can rotate one string to get another one. ‘Rotate’ here means ‘‘to take some consecutive chars (maybe none) from the beginning of a string and

2020-08-13 21:05:31 272

原创 Codeforces1395 D. Boboniu Chats with Du(贪心)

Have you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days.In Boboniu’s chat group, there’s a person called Du Yi who likes to make fun of Boboniu every day.Du will chat in the group for ???? days.

2020-08-13 11:56:38 1214

原创 Codeforces C. Boboniu and Bit Operations(按位或者状压)

Boboniu likes bit operations. He wants to play a game with you.Boboniu gives you two sequences of non-negative integers ????1,????2,…,???????? and ????1,????2,…,????????.For each ???? (1≤????≤????), you’re asked to choose a ???? (1≤????≤????) and let ???

2020-08-13 11:53:43 345

原创 Codeforces1395 B.Boboniu Plays Chess

Boboniu likes playing chess with his employees. As we know, no employee can beat the boss in the chess game, so Boboniu has never lost in any round.You are a new applicant for his company. Boboniu will test you with the following chess question:Consider

2020-08-13 11:48:42 521

空空如也

空空如也

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

TA关注的人

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