C. The Number Of Good Substrings Problem Description: You are given a binary string s (recall that a string is binary if each character is either 0 or 1).Let f(t) be the decimal representation of integer t written in binary form (possibly with leadin…
Problem Description: You are fighting with Zmei Gorynich — a ferocious monster from Slavic myths, a huge dragon-like reptile with multiple heads!Initially Zmei Gorynich has x heads. You can deal n types of blows. If you deal a blow of the i-th type,…
Problem Description: You play your favourite game yet another time. You chose the character you didn't play before. It has str points of strength and int points of intelligence. Also, at start, the character has exp free experience points you can inv…
Educational Codeforces Round 72 (Rated for Div. 2)-D. Coloring Edges-拓扑排序 [Problem Description] ​ 给你一个有向图,给用最少的颜色给每条边染色,要保证不存在一个环中的所有边都是同一个颜色. [Solution] ​ 用拓扑排序判断图中是否存在环,若图中不存在环,则所有边都是同一种颜色.否则,同一个环中,只要用两种颜色就可以满足题目条件,所以总的颜色数就是两种,对于一个环,一定会存在两种边:1.节点号小…
https://codeforces.com/contest/1217 D:给定一个有向图,给图染色,使图中的环不只由一种颜色构成,输出每一条边的颜色 不成环的边全部用1染色 ps:最后输出需要注意,一个环上的序号必然是非全递增的,若有环且有一条边u->v,u的序号<v则输出1否则输出2(反过来也可以) 可以用dfs染色或者用拓扑排序做 顺便复习一下拓扑排序: 拓扑排序是将有向无环图的所有顶点排成一个线性序列,使得图中任意两个顶点u,v若存在u->v,那么序列中u一定在v前面. 了解一个…
https://www.cnblogs.com/31415926535x/p/11601964.html 这场只做了前四道,,感觉学到的东西也很多,,最后两道数据结构的题没有补... A. Creating a Character 贪心加一堆判断就行了,,, #include <bits/stdc++.h> #define aaa cout<<233<<endl; #define endl '\n' using namespace std; typedef long l…
题意:https://codeforc.es/contest/1217/problem/D 给你一个有向图,要求一个循环里不能有相同颜色的边,问你最小要几种颜色染色,怎么染色? 思路: 如果没有环,那全是1:如果有环,那小到大的边为1,大到小的边为2. #define IOS ios_base::sync_with_stdio(0); cin.tie(0); #include <cstdio>//sprintf islower isupper #include <cstdlib>/…
传送门 A. Creating a Character 设读入的数据分别为 $a,b,c$ 对于一种合法的分配,设分了 $x$ 给 $a$ 那么有 $a+x>b+(c-x)$,整理得到 $x>(b+c-a)/2$ 因为 $x \in [0,c]$ ,所以求一下区间交的大小即可,注意 (b+c-a) 可能小于 0 #include<iostream> #include<cstdio> #include<algorithm> #include<cstrin…
#define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;#define BUF_SIZE 100000bool IOerror=0;//加了读入挂才1900ms+卡ddl过的,不加读入代码tleT_Tinline char nc(){ static char buf[BUF_SIZE], *p1=buf+BUF_SIZE, *pend=buf+BUF_SIZE; if(p1==pend){ p1=buf; p…
#define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;char s[200007];int a[200007][20];int main(){ int t; cin>>t; while(t--){ cin>>s+1; int n=strlen(s+1); for(int i=0;i<=n;++i) for(int j=0;j<=18;++j) a[i][j]=0; for…
#define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;int n,m,k=1;int c[5007],vis[5007];vector<int>v[5007],no[5007];void dfs(int u){ vis[u]=-1; for(int i=0;i<v[u].size();++i){ int t=v[u][i]; int x=no[u][i]; if(vis[t]==-1){/…
链接 直接用数组记录每个字母的个数即可 #include<bits/stdc++.h> using namespace std; int a[26] = {0}; int b[26] = {0}; int judge() { //cout<<"111"<<endl; for (int i = 0; i < 26; ++i) { if (a[i]!=b[i]) { return 0; } } return 1; } int main() { //…
题意: 给你n个关卡,每个关卡有一个怪物,怪物的攻击力为a[i],你有n个英雄,每个英雄有一个攻击力,和疲劳值,只要英雄的攻击力比怪物的高就算打过了,同时疲劳减一,一天只能出战一个英雄,一个英雄可以打好几关(只要在疲劳范围内),打不过的话英雄就结束今天的挑战,转到第二天.问最少需要出战多少英雄才能通过所有关卡. 思路:先用一个数组.跑出相同忍耐值时,攻击力越大.然后·跑出这个数组的后缀pre数组,pre数组的含义是:忍耐值一定,攻击力最大.然后通过O(n)的复杂度跑·怪物的数组.当怪物的a[i]…
题意:给出一个字符串s, 可以从左往右拿走s的字符, 至少要到s的第几个位置才能拼成t 思路:用二维数组记录前缀,然后二分即可. #include<bits/stdc++.h> using namespace std; #define inf 5000000 #define N 210050 ]; ]; string s; string str; int n; bool slove(int id) { ; i<; i++) ) return false; return true; } i…
慢慢来. 题目册 题目 A B C D E F G 状态 √ √ √ √ × ∅ ∅ //√,×,∅ 想法 A. Prime Subtraction res tp A 题意:给定\(x,y(x>y)\),问能否将\(x-y\)拆成任意多个质数之和 1.任意大于\(1\)的整数\(k\)都可以用\(2\)与\(3\)的线性表示 证: 若\(k\)是偶数,显然: 若\(k\)是奇数,则\(k\)可以表示成\(k = 3 + 2*k'\),显然: 毕. #include<bits/stdc++.h&…
B. The Modcrab Vova is again playing some computer game, now an RPG. In the game Vova's character received a quest: to slay the fearsome monster called Modcrab. After two hours of playing the game Vova has tracked the monster and analyzed its tactics…
D. Credit Card Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card. She starts with 0 money on her account. In the evening of i-th day a transaction ai occurs. If ai > 0, then ai bourles are dep…
C. Rumor Vova promised himself that he would never play computer games... But recently Firestorm — a well-known game developing company — published their newest game, World of Farcraft, and it became really popular. Of course, Vova started playing it…
B. Beautiful Divisors Recently Luba learned about a special kind of numbers that she calls beautiful numbers. The number is called beautiful iff its binary representation consists of k + 1 consecutive ones, and then k consecutive zeroes. Some example…
A. Chess For Three Alex, Bob and Carl will soon participate in a team chess tournament. Since they are all in the same team, they have decided to practise really hard before the tournament. But it's a bit difficult for them because chess is a game fo…
A. Remove a Progression 签到题,易知删去的为奇数,剩下的是正偶数数列. #include<iostream> using namespace std; int T; int n,x; int main(){ cin>>T; while(T--){ cin>>n>>x; cout<<x * 2<<endl; } return 0; } B. Yet Another Crosses Problem n*m存在上界,…
Problem   Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec Problem Description Input Output The only line should contain the minimal number of days required for the ship to reach the point (x2,y2)(x2,y2). If it…
Problem   Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec Problem Description Input The input contains a single line consisting of 2 integers N and M (1≤N≤10^18, 2≤M≤100). Output Print one integer, the total n…
Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include<bits/stdc++.h> using namespace std; #define lson l,mid,rt<<1 #define rson mid+1,r,rt<<1|1 #define IT set<ll>::iterator #define sqr(x)…
Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include<bits/stdc++.h> using namespace std; #define lson l,mid,rt<<1 #define rson mid+1,r,rt<<1|1 #define IT set<ll>::iterator #define sqr(…
Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings 题目连接: http://codeforces.com/contest/985/problem/F Description You are given a string s of length n consisting of lowercase English letters. For two given strings s an…
Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes 题目连接: http://codeforces.com/contest/985/problem/E Description Mishka received a gift of multicolored pencils for his birthday! Unfortunately he lives in a monochrome w…
Educational Codeforces Round 63 (Rated for Div. 2)题解 题目链接 A. Reverse a Substring 给出一个字符串,现在可以对这个字符串进行一次翻转,问是否存在一种方案,可以使得翻转后字符串的字典序可以变小.   这个很简单,贪心下就行了. 代码如下: Code #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 3e5…
Educational Codeforces Round 39 (Rated for Div. 2) G 题意: 给一个序列\(a_i(1 <= a_i <= 10^{9}),2 <= n <= 200000\), 如果至多删除其中的一个数之后该序列为严格上升序列,那么称原序列为几乎严格上升序列. 现在每次将序列中的任意数字变成任意数字,问最少要操作几次才能将序列变成几乎严格上升子序列. 思路: 如果不考虑删除,求让整个序列都变成严格上升子序列的次数 求出\(序列a_i - i\)…
Educational Codeforces Round 48 (Rated for Div. 2) C. Vasya And The Mushrooms 题目链接:https://codeforces.com/contest/1016/problem/C 题意: emmm,说不清楚,还是直接看题目吧. 题解: 这个题人行走的方式是有一定的规律的,最后都是直接走到底,然后从另外一行走回来.并且通过画图观察,会发现他走到格子的时间会有一定的规律. 所以就维护几个前缀和就行了,从1到n枚举一下,还要…