- 博客(155)
- 收藏
- 关注
原创 Educational Codeforces Round 93 (Rated for Div. 2)
A.Bad Triangle题意:给定一组非递减序列,是否有a+b<=c的非三角形边组合,如果有,输出其边的序列号,否则输出-1。思路:因为是递增的,所以a+b和c差距最大的就是1,2和n,如果a1+a2>an 那么其序列的所有排列组合都是合法的三角形边,即不存在三条边,输出-1,否则就输出1,2,和n。#include<iostream>using namespace std;typedef long long ll;const int maxn=1234..
2020-08-16 01:29:44 239
原创 2020牛客多校(十)
E:Game题意:给定一个格子的从左到右的摆放序列,你可以将任意的格子由右向左移动,求可能得到的排列中最大的格子是最小的。思路:因为格子只能由右向左移,所以从左向右不断相加其平均值的最大,不断更新该值,即可求出最小的最大值。#include<bits/stdc++.h>using namespace std;long long a[123456];int main(){ int T, n; cin >> T; while(T--) //1e5 {
2020-08-16 01:14:40 265
原创 牛客多校(第九场)
A Groundhog and 2-Power Representation 题意:给定一个式子,括号代表次幂级,只可能是2的次幂。不会python的本菜鸡用了栈,很难写明白,最后失败了。(体会到了python库的强大def T(x): return pow(2,x)s=input()s=s.replace('2(','T(')print(eval(s))...
2020-08-09 14:20:43 298
原创 牛客多校(第八场)
I Interesting Computer Game 题目描述:T个样例,每个样例给定一个n,进行n次分发,每次分发两个数字a[i],b[i]。每次可以选择取一个,也可以不取。求最多可以取到数字的个数。(final级的签到了TAT)思路:离散化的并查集(代码出自赵大神)#include <iostream>#include <iomanip>#include <cstdio>#include <cstdlib>.
2020-08-09 11:45:46 115
原创 Codeforces Round #661 (Div. 3) D. Binary String To Subsequences
Codeforces Round #661 (Div. 3)Binary String To Subsequences题目链接题意01的无序串中,找到010101……或10101……的有序子串,并进行序号标记。用栈没写出来,看了别人代码之后,vector写的,用栈应该也可以,还是太菜了。#include<iostream>#include<vector>using namespace std;int t,n,m[223456];string s;int mai
2020-08-09 10:39:20 150
原创 Engines AtCoder - 4900
EnginesProblem StatementE869120 is initially standing at the origin (0,0) in a two-dimensional plane.He has N engines, which can be used as follows:When E869120 uses the i-th engine, his X-...
2020-05-08 11:40:42 142
原创 C. Phoenix and Distribution
题目链接很简单的分类问题,给出一个长为n的字符串,分为k个字段,使k个子串中字典序最大的尽可能最小;简单的方法就是将输入的n个字符重新排序,当s[0]!=s[k-1]时,证明当最小字典序的字符不可以作为所有k个子串的第一个字符,此时最大字典序最小的子串一定为s[k-1],s[0]==s[k-1]时,判断s[k]是否等于s[n-1],若相等,则将其后字符均分在k个子串,有余则加一,既(s[0...
2020-05-02 14:56:49 384
原创 1296C Yet Another Walking Robot (Codeforces)(map)
Yet Another Walking Robot 题目链接题意:输入一段路径,输出最短的重复段。思路:每走一步将到达的点存入map,进行判重,并保存最小值;#include<iostream>#include<map>using namespace std;struct node{ int x,y; friend bool opera...
2020-02-07 17:15:28 206
原创 Codeforces Round #614 (Div. 2)C NEKO's Maze Game
NEKO's Maze GameIce - DJ Mashiro is dead or aliveNEKO#ΦωΦ has just got a new maze game on her PC!The game's main puzzle is a maze, in the forms of a 2×n rectangle grid. NEKO's task is to lead a ...
2020-01-20 12:38:22 458 3
原创 算法协会19级STL训练赛题解
Let the Balloon Rise HDU - 1004不重复数字 HYSBZ - 2761{A} + {B} HDU - 1412Ignatius and the Princess IV HDU - 1029(map)Andy's First Dictionary UVA - 10815
2019-12-15 15:53:35 223
原创 Andy's First Dictionary UVA - 10815
Andy's First Dictionary题目链接这道题的要求将所有出现的单词按照顺序输出,完全符合set去重并且自动排序的功能,我们就可以选择用set进行代码实现。在进行样例测试的时候可能会有问题,回车总是代表一个字符串的结束标记符,在这里我们要进行多组输入,所以我们在输入未知的多组字符串后要结束多组输入,及使该输入达到end of file时结束多组输入,Crtl+z即代表EO...
2019-12-15 15:50:06 275
原创 Ignatius and the Princess IV HDU - 1029(map)
Ignatius and the Princess IV题目链接这道题给出的测试样例都一定存在一个special integer。我们可以利用数组进行存储及遍历,也可以用map进行存储。#include<iostream>#include<map>using namespace std;map<int,int>ma;int main...
2019-12-15 15:30:03 175
原创 {A} + {B} HDU - 1412
题目链接题意要求是去重,并且输出顺序是从小到大,所以完全符合set自动去重和排序的特点。#include<iostream>#include<algorithm>#include<set>using namespace std;int n,m;int main(){ while(cin>>n>>m){ s...
2019-11-29 20:43:21 149
原创 不重复数字 HYSBZ - 2761
题目链接题意要求就是去重,并且输出顺序不改变,只保留第一次出现的元素。set和map都可实现(map内部会自动排序,所以需要边存入map,判断是否是第二个及以上出现的元素,随即输出)/*set*/#include<iostream>#include<algorithm>#include<set>using namespace std;...
2019-11-29 20:35:24 203
原创 Let the Balloon Rise HDU - 1004
题目链接map经典水题。#include<iostream>#include<map>using namespace std;#define ll long longconst int MAXN=200010;map<string,int> ma;int main(){ int n; while(cin>>n&&...
2019-11-29 20:27:40 151
原创 Valeriy and Deque CodeForces - 1180C(deque)
Valeriy and DequeRecently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with nn elements. The ii -th element is aiai (ii = 1,2,…,n1,2,...
2019-11-28 20:10:27 251
原创 Pairs CodeForces - 1169B
PairsToad Ivan has mm pairs of integers, each integer is between 11 and nn , inclusive. The pairs are (a1,b1),(a2,b2),…,(am,bm)(a1,b1),(a2,b2),…,(am,bm) .He asks you to check if there exist two in...
2019-11-25 21:59:31 310
原创 Circle Metro CodeForces - 1169A
Circle MetroThe circle line of the Roflanpolis subway has nn stations.There are two parallel routes in the subway. The first one visits stations in order 1→2→…→n→1→2→…1→2→…→n→1→2→… (so the next st...
2019-11-25 20:52:46 229
原创 Nick and Array CodeForces - 1180B
Nick and ArrayNick had received an awesome array of integers a=[a1,a2,…,an]a=[a1,a2,…,an] as a gift for his 55 birthday from his mother. He was already going to explore its various properties but af...
2019-11-25 20:17:03 195
原创 Engines AtCoder - 4900
EnginesProblem StatementE869120 is initially standing at the origin (0,0) in a two-dimensional plane.He has N engines, which can be used as follows:When E869120 uses the i-th engine, his X-...
2019-11-24 15:38:22 281
原创 Shortest Path on a Line AtCoder - 5635
Shortest Path on a LineProblem StatementWe have N points numbered 1 to N arranged in a line in this order.Takahashi decides to make an undirected graph, using these points as the vertices. In...
2019-11-23 17:35:34 207
原创 题(背包)
悼念512汶川大地震遇难同胞——珍惜现在,感恩生活急!灾区的食物依然短缺!为了挽救灾区同胞的生命,心系灾区同胞的你准备自己采购一些粮食支援灾区,现在假设你一共有资金n元,而市场有m种大米,每种大米都是袋装产品,其价格不等,并且只能整袋购买。请问:你用有限的资金最多能采购多少公斤粮食呢?后记:人生是一个充满了变数的生命过程,天灾、人祸、病痛是我们生命历程中不可预知的威胁。月有阴晴圆缺,人...
2019-11-22 21:49:41 819
原创 Counting of Trees AtCoder - 5633
Counting of TreesProblem StatementGiven is an integer sequence D1,…,DN of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following cond...
2019-11-21 21:18:14 231
原创 AB Substrings AtCoder - 5039
AB SubstringsProblem StatementSnuke has N strings. The i-th string is si.Let us concatenate these strings into one string after arranging them in some order. Find the maximum possible number ...
2019-11-18 21:08:08 161
原创 Kleene Inversion AtCoder - 5165
Kleene InversionProblem StatementWe have a sequence of N integers A~=~A0,~A1,~…,~AN−1.Let B be a sequence of K×N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 ...
2019-11-18 21:00:02 325 2
原创 Lower AtCoder - 4871
LowerProblem StatementThere are N squares arranged in a row from left to right.The height of the i-th square from the left is Hi.You will land on a square of your choice, then repeat moving...
2019-11-18 20:49:47 129
原创 Powerful Discount Tickets AtCoder - 4864
Powerful Discount TicketsProblem StatementTakahashi is going to buy N items one by one.The price of the i-th item he buys is Ai yen (the currency of Japan).He has M discount tickets, and he...
2019-11-18 20:33:13 242
原创 Monsters Battle Royale AtCoder - 4297
Monsters Battle RoyaleProblem StatementThere are N monsters, numbered 1,2,…,N.Initially, the health of Monster i is Ai.Below, a monster with at least 1 health is called alive.Until there ...
2019-11-18 20:08:11 259
原创 ModSum(思维)
ModSumProblem StatementFor an integer N, we will choose a permutation {P1,P2,…,PN} of {1,2,…,N}.Then, for each i=1,2,…,N, let Mi be the remainder when i is divided by Pi.Find the maximum po...
2019-11-18 19:36:22 356
原创 一周补题集
以下是每道题的链接:ModSum(思维)Monsters Battle RoyalePowerful Discount TicketsLowerKleene InversionAB Substrings Counting of TreesShortest Path on a LineEngines
2019-11-16 15:19:28 98
原创 RGB Substring (easy version)
RGB Substring (easy version)The only difference between easy and hard versions is the size of the input.You are given a string ss consisting of nn characters, each character is 'R', 'G' or 'B'.Y...
2019-11-16 15:09:39 306
原创 Cotree
CotreeAvin has two trees which are not connected. He asks you to add an edge between them to make them connected while minimizing the function ∑ni=1∑nj=i+1dis(i,j)∑i=1n∑j=i+1ndis(i,j), where dis(i,j...
2019-11-13 21:42:47 238
原创 Rng (规律+逆元+概率)
RngAvin is studying how to synthesize data. Given an integer n, he constructs an interval using the following method: he first generates a integer r between 1 and n (both inclusive) uniform-randomly...
2019-11-11 21:45:10 603
原创 Wave (dp/暴力)
WaveAvin is studying series. A series is called "wave" if the following conditions are satisfied:1) It contains at least two elements;2) All elements at odd positions are the same;3) All elements...
2019-11-10 20:10:09 263
原创 Worker (二分)
WorkerAvin meets a rich customer today. He will earn 1 million dollars if he can solve a hard problem. There are n warehouses and m workers. Any worker in the i-th warehouse can handle ai orders per...
2019-11-10 18:40:29 506
原创 Traffic(暴力模拟)
TrafficAvin is observing the cars at a crossroads. He finds that there are n cars running in the east-west direction with the i-th car passing the intersection at time ai . There are another m cars ...
2019-11-10 18:28:51 751
原创 Budget (思维)
BudgetAvin’s company has many ongoing projects with different budgets. His company records the budgets using numbers rounded to 3 digits after the decimal place. However, the company is updating the...
2019-11-10 17:50:47 565
原创 Fixing Banners(DFS)
Fixing BannersHarbin, whose name was originally a Manchu word meaning "a place for drying fishing nets", grew from a small rural settlement on the Songhua River to become one of the largest citi...
2019-11-03 10:57:11 721 1
原创 HDU 6227 Rabbits (思维)
RabbitsHere N (N ≥ 3) rabbits are playing by the river. They are playing on a number line, each occupying a different integer. In a single move, one of the outer rabbits jumps into a space between a...
2019-10-15 21:38:32 223
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人