Codeforces
菜鸡日常刷题.....
菱形继承
懒癌患者,IT民工,前进路上经常磕磕碰碰
展开
-
Codeforces Round #710 (Div. 3) G. Maximize the Remaining String(单调栈、模拟)
有以下事实:当后一个字符比前一个字符大,并且前一个字符后面还有出现,则删除之如果这个字符是这种字符出现的最后一个位置,则加入,并在之后不能删除同种字符只能在答案出现一次#include<bits/stdc++.h>using namespace std;const int N=1e4+10;int main(){ string s; int t; cin>>t; while(t--){ cin>>s; map<char,i..原创 2021-03-27 10:59:28 · 145 阅读 · 0 评论 -
Codeforces Round #710 (Div. 3) E. Restoring the Permutation(贪心、模拟)
维护一个当前可以插入数的set如果当前数等于上一个数,那么字典序最大序列答案就是set最大值,取出并删除、字典序最小序列答案就是set最小值,取出并删除如果不等,那么最大序列和最小序列这个位置的数就是该数#include<bits/stdc++.h>using namespace std;#define ll long longconst int N=2e5+10;ll t,a[N],maxx[N],minn[N]; int main(){ cin>>..原创 2021-03-27 10:56:26 · 194 阅读 · 0 评论 -
Codeforces Round #710 (Div. 3) D. Epic Transformation(优先队列、贪心)
这题首先可以先找每个数出现次数,然后开一个优先队列,从大到小,最正确的贪心策略是每次最大数和次大数减去(次大数与第三大数差+1)---(可以证明)#include<bits/stdc++.h>using namespace std;#define ll long longconst int N=2e5+10;ll t,a[N];int main(){ cin>>t; while(t--){ int x; map<int,int>p; ..原创 2021-03-27 10:53:52 · 242 阅读 · 0 评论 -
Codeforces Round #710 (Div. 3) C. Double-ended Strings(暴力、哈希)
这题本质上是lcs,但是比赛的时候直接暴力了,数据范围过小,直接n3枚举存map然后暴力算答案#include<bits/stdc++.h>using namespace std;#define ll long longconst int N=1e5+10;ll t;int main(){ cin>>t; while(t--){ string a,b; map<string,int>pa,pb; cin>>a>>..原创 2021-03-27 10:50:34 · 174 阅读 · 0 评论 -
Codeforces Round #710 (Div. 3) B. Partial Replacement(贪心)
这道题贪心做,找最大k范围内的字符 ,注意首位都要取的条件#include<bits/stdc++.h>using namespace std;#define ll long longconst int N=1e5+10;ll t;int main(){ cin>>t; while(t--){ int n,k; cin>>n>>k; string s; cin>>s; vector<int>p..原创 2021-03-27 10:47:36 · 182 阅读 · 0 评论 -
Codeforces Round #710 (Div. 3) A. Strange Table(推导)
找一下竖着排的行标和列标的规律,然后答案就是行*(列数-1)+列#include<bits/stdc++.h>using namespace std;#define ll long longconst int N=1e5+10;ll t;int main(){ cin>>t; while(t--){ ll n,m,x; cin>>n>>m>>x; ll row=x%n,col=x/n+(x%n!=0); if..原创 2021-03-27 10:39:49 · 258 阅读 · 0 评论 -
Codeforces Round #633 (Div. 2)D Edge Weight Assignment(构造、树的权值异或)
Edge Weight Assignmenttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have unweighted tree ofnnvertices. You have to assign...原创 2020-04-13 09:17:31 · 428 阅读 · 9 评论 -
Codeforces Round #633 (Div. 2) A Filling Diamonds (假题,观察)
Filling Diamondstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have integernn. Calculate how many ways are there to fully c...原创 2020-04-13 09:01:51 · 440 阅读 · 0 评论 -
Codeforces Round #633 (Div. 2)C Powered Addition (贪心,二进制)
Powered Additiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have an arrayaaof lengthnn. For every positive integerxx...原创 2020-04-13 08:58:02 · 417 阅读 · 0 评论 -
Codeforces Round #633 (Div. 2) B Sorted Adjacent Differences(直观感知+排序插放)
Sorted Adjacent Differencestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have array ofnnnumbersa1,a2,…,ana1,a2,…,an.Re...原创 2020-04-13 08:51:39 · 385 阅读 · 0 评论 -
Codeforces Beta Round #51 C. Pie or die(博弈 思维)
C. Pie or dietime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVolodya and Vlad play the following game. There arekpies at the c...原创 2020-04-03 17:39:34 · 238 阅读 · 0 评论 -
Codeforces Round #629 (Div. 3) F. Make k Equal (技巧暴力,类前缀和,思维,数学)
F. Make k Equaltime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given the arrayaaconsisting ofnnelements and the inte...原创 2020-03-30 21:17:28 · 309 阅读 · 17 评论 -
Codeforces 727D-T-shirts Distribution (字符串 贪心)
D. T-shirts Distributiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe organizers of a programming contest have decided to p...原创 2020-03-19 19:59:47 · 256 阅读 · 0 评论 -
Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 1) B. Bear and Blocks (技巧dp 难想)
B. Bear and Blockstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLimak is a little bear who loves to play. Today he is playing b...原创 2020-03-19 16:41:29 · 198 阅读 · 0 评论 -
Codeforces Round #382 (Div. 2) D. Taxes (数论 哥猜 大胆尝试)
D. Taxestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMr. Funt now lives in a country with a very specific tax laws. The total...原创 2020-03-19 11:44:20 · 179 阅读 · 0 评论 -
CodeForces 23B (图论 思维)
npeople came to a party. Then those, who had no friends among people at the party, left. Then those, who had exactly 1 friend among those who stayed, left as well. Then those, who had exactly2,3,......原创 2020-03-16 22:57:27 · 318 阅读 · 0 评论 -
Codeforces Round #627 (Div. 3) E. Sleeping Schedule (DP)
E. Sleeping Scheduletime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVova had a pretty weird sleeping schedule. There arehhhour...原创 2020-03-14 20:23:25 · 273 阅读 · 0 评论 -
Codecraft-17 and Codeforces Round #391 (Div. 1 + Div. 2, combined) B. Bash's Big Day (Hash+简单数论)
B. Bash's Big Daytime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputBash has set out on a journey to become the greatest Pokemon ma...原创 2020-03-14 16:46:35 · 226 阅读 · 0 评论 -
Codeforces Round #424 (Div. 1, rated, based on VK Cup Finals) B. Cards Sorting 树状数组+技巧
B. Cards Sortingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasily has a deck of cards consisting ofncards. There is an int...原创 2020-03-13 17:31:33 · 209 阅读 · 0 评论 -
Codeforces Round #625 (Div. 2, based on Technocup 2020 Final Round) C. Remove Adjacent
C. Remove Adjacenttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a stringssconsisting of lowercase Latin letter...原创 2020-03-02 11:19:38 · 417 阅读 · 0 评论 -
Codeforces Round #624 (Div. 3) D.Three Integers
Three IntegersThree Integerstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given three integersa≤b≤ca≤b≤c.In one m...原创 2020-02-25 17:14:19 · 476 阅读 · 1 评论 -
Codeforces Round #624 (Div. 3) C - Perform the Combo
Perform the ComboPerform the Combotime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou want to perform the combo on your oppone...原创 2020-02-25 16:26:28 · 494 阅读 · 0 评论 -
Codeforces Round #624 (Div. 3) B - WeirdSort
B - WeirdSorttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an arrayaaof lengthnn.You are also given a set o...原创 2020-02-25 16:24:35 · 428 阅读 · 0 评论 -
Codeforces Round #624 (Div. 3) A - Add Odd or Subtract Even
Add Odd or Subtract Eventime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two positive integersaaandbb.In one m...原创 2020-02-25 16:19:55 · 392 阅读 · 0 评论 -
Codeforces Round #622 (Div. 2) A.Fast Food Restaurant
Fast Food Restauranttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTired of boring office work, Denis decided to open a fast foo...原创 2020-02-24 12:10:59 · 457 阅读 · 0 评论 -
Codeforces Round #605 (Div. 3) D. Remove One Element
D. Remove One Elementtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an arrayaaconsisting ofnnintegers.You c...原创 2020-02-02 20:52:32 · 220 阅读 · 0 评论 -
Educational Codeforces Round 81 (Rated for Div. 2) C.Obtain The String
题目链接题意:串S,T,T是目标串,你需要将一个空串变成T,通过将S的任意子串添加到这个要变成T的串后头,这里的子串可以是不连续的,问最少次数,做不到就-1讲道理做这种题目没技巧,就是很直接,但是要认真分析出来,你要添加一个字符就去S里找最早出现的嘛,贪心很好理解,然后下一个字符看看有没有在这个最早出现位置的后头,要是有,ok接着如上操作否则答案+1,无解的情况很简单就是没有这个字符嘛...原创 2020-02-01 12:19:23 · 198 阅读 · 0 评论 -
Educational Codeforces Round 81 (Rated for Div. 2) B - Infinite Prefixes
Infinite Prefixestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given stringsof lengthnnconsisting of0-s and1-s. ...原创 2020-02-01 11:52:14 · 315 阅读 · 0 评论 -
Educational Codeforces Round 81 (Rated for Div. 2) A. Display The Number
Display The Numbertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have a large electronic screen which can display up to9982...原创 2020-02-01 11:35:20 · 233 阅读 · 0 评论 -
Codeforces Round #615 (Div. 3) F. Three Paths on a Tree
F. Three Paths on a Treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an unweighted tree withnnvertices. Recal...原创 2020-01-24 15:26:29 · 464 阅读 · 0 评论 -
Codeforces Round #615 (Div. 3) E. Obtain a Permutation
E. Obtain a Permutation题目链接:https://codeforces.com/contest/1294/problem/E题意:给你一个 n * m 的矩阵,你执行两种操作:① 把矩阵中任意一个元素改为任意一个数② 把矩阵中任意一列整体往上挪一个单元格,如下图矩阵我们对第一列向上挪了一个单元格现要求用最少的操作次数使矩阵内每一个元素 a[i][j] ...原创 2020-01-24 15:20:16 · 287 阅读 · 0 评论 -
Codeforces Round #615 (Div. 3)D. MEX maximizing
题目链接:https://codeforces.com/contest/1294/problem/D题意:给你 q 个询问和 一个 x , 每次询问输入一个数 n,你可以把它减任意次 x 或 加任意次 x,然后添入数组,问每次询问结束时数组里最小的没出现的非负整数是多少其实这里面的MEX函数是博弈论中sg函数的一个重要组成部分,MEX函数定义为数组里最小的没出现的非负整数...原创 2020-01-24 15:09:03 · 338 阅读 · 0 评论 -
Codeforces Round #615 (Div. 3)C. Product of Three Numbers
C. Product of Three Numberstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given one integer numbernn. Find threedisti...原创 2020-01-24 14:53:50 · 197 阅读 · 0 评论 -
Codeforces Round #615 (Div. 3)B. Collecting Packages
B. Collecting Packagestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a robot in a warehouse andnnpackages he wants to...原创 2020-01-24 14:41:06 · 381 阅读 · 0 评论 -
Codeforces Round #615 (Div. 3)A. Collecting Coins
A. Collecting Coinstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp has three sisters: Alice, Barbara, and Cerene. They'...原创 2020-01-24 14:32:50 · 615 阅读 · 0 评论 -
Codeforces Round #613 (Div. 2)B. Just Eat It!
B. Just Eat It!time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputToday, Yasser and Adel are at the shop buying cupcakes. There are...原创 2020-01-19 19:14:53 · 333 阅读 · 0 评论 -
Codeforces Round #613 (Div. 2)A. Mezo Playing Zoma
A. Mezo Playing Zomatime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputToday, Mezo is playing a game. Zoma, a character in that game...原创 2020-01-19 19:10:37 · 329 阅读 · 0 评论 -
Codeforces Round #547 (Div. 3)G. Privatization of Roads in Treeland
G. Privatization of Roads in Treelandtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTreeland consists ofncities andn−1roads...原创 2019-08-09 16:21:09 · 463 阅读 · 0 评论 -
Codeforces Round #547 (Div. 3)F2. Same Sum Blocks (Hard)
F2. Same Sum Blocks (Hard)time limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis problem is given in two editions, which differ ex...原创 2019-08-09 16:15:30 · 466 阅读 · 0 评论 -
Codeforces Round #547 (Div. 3)F1. Same Sum Blocks (Easy)
F1. Same Sum Blocks (Easy)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis problem is given in two editions, which differ ex...原创 2019-08-09 16:06:49 · 487 阅读 · 0 评论