codeforces
c_3Po_
这个作者很懒,什么都没留下…
展开
-
Codeforces Round #621 (Div. 1 + Div. 2) D-Cow and Fields
题目链接题意:给你一个图,在这个图中有k个特殊点,然后选择两个特殊点连边,问你1到n的最短路最大是多少。做法:正反各跑一次最短路。考虑贪心,把特殊点按和1的距离从小到大排序,枚举相邻的两个特殊点加边代码如下:package mainimport ( "bufio" "fmt" "os" "sort" "strconv" "sync")type Edg...原创 2020-02-18 16:52:07 · 130 阅读 · 0 评论 -
Codeforces Round #553 (Div. 2) D
贪心,按ab差值排序 #include <bits/stdc++.h>using namespace std;typedef long long ll;struct node{ ll a,b;}d[100005];bool cmp(node A,node B){ return (A.a-A.b)>(B.a-B.b);}int main(){ i...原创 2019-05-01 17:30:30 · 100 阅读 · 0 评论 -
Codeforces Round #553 (Div. 2)A
模拟,连续的4个#include <bits/stdc++.h>using namespace std;char s[100];int ans = 100000000;int solve(char a, char b){ a = a - 'A', b = b - 'A'; return min((a - b + 26) % 26, (b - a + 26) % 2...原创 2019-04-29 17:39:39 · 68 阅读 · 0 评论 -
Codeforces Round #552 (Div. 3) E
#include <bits/stdc++.h>using namespace std;typedef long long ll;typedef unsigned long long ull;const int maxn=2e5+5;list<pair<int, int>>l;list<pair<int, int>>:...原创 2019-04-29 17:36:12 · 72 阅读 · 0 评论 -
Codeforces Round #552 (Div. 3) D
模拟就完事了#include <bits/stdc++.h>using namespace std;typedef long long ll;typedef unsigned long long ull;const int maxn=2e5+5;int n, b, a, mxa, arr[maxn];int main() { scanf("%d %d %d", ...原创 2019-04-29 17:28:10 · 91 阅读 · 0 评论 -
Codeforces Round #552 (Div. 3) B
给你n个数,可以不变,可以加上D,可以减去D,能否变成同一个数,输出最小的D#include <bits/stdc++.h>using namespace std;typedef long long ll;typedef unsigned long long ull;const int maxn=2e5+5;int a[maxn],cnt;std::vector<...原创 2019-04-29 17:23:41 · 140 阅读 · 0 评论 -
Codeforces Round #552 (Div. 3) C
3种东西,指定星期几可以使用,问你最多能用几天#include <bits/stdc++.h>using namespace std;typedef long long ll;ll x[3], z[3];int y[] = { 0, 1, 2, 0, 2, 1, 0 };int main(){ cin >> x[0] >> x[1] >...原创 2019-04-29 17:18:32 · 79 阅读 · 0 评论 -
Codeforces Round #552 (Div. 3) A
找到最大的依次减一下就行了#include <bits/stdc++.h>using namespace std;typedef long long ll;const int maxn=1e5+5;int main(int argc, char const *argv[]){ int a[5]; for(int i=0;i<4;i++) { cin...原创 2019-04-29 17:11:03 · 82 阅读 · 0 评论 -
Codeforces Round #555 (Div. 3) C1
给你n个数,都不同,每次可以从左边或者右边取一个数,要求每次取的数都要比上一次取的数大,问最多能取多少个数。贪心,模拟着取就行了#include <bits/stdc++.h>using namespace std;typedef long long ll;typedef unsigned long long ull;const int maxn=2e5+5;in...原创 2019-04-29 17:07:49 · 93 阅读 · 0 评论 -
Codeforces Round #555 (Div. 3) B
给你一串数字,还有一组映射关系,选择连续的一段子串,改变一下#include <bits/stdc++.h>using namespace std;typedef long long ll;typedef unsigned long long ull;const int maxn=2e5+5;char s[maxn];int mp[15];signed main()...原创 2019-04-29 17:05:34 · 94 阅读 · 0 评论 -
Codeforces Round #553 (Div. 2) E
考虑每条边的贡献#include <bits/stdc++.h>using namespace std;typedef long long ll;const int maxn=1e5+5;ll a[maxn],n;ll ans;int main(int argc, char const *argv[]){ cin>>n; for(int i=1...原创 2019-04-30 20:59:54 · 233 阅读 · 0 评论 -
Codeforces Round #553 (Div. 2) B
枚举#include <bits/stdc++.h>using namespace std;typedef long long ll;const int maxn=1e5+5;int mp[505][505],n,m,ans;int main(int argc, char const *argv[]){ scanf("%d%d",&n,&m);...原创 2019-05-01 17:30:22 · 125 阅读 · 0 评论 -
Educational Codeforces Round 63 (Rated for Div. 2) A
扫一遍,发现当前上一个小,直接交换 输出就行了#include <bits/stdc++.h>using namespace std;typedef long long ll;const int maxn =3e5+10;const int INF=0x3f3f3f3f;char s[maxn];int main(int argc, char const *argv...原创 2019-04-30 20:59:49 · 211 阅读 · 0 评论 -
Codeforces Round #555 (Div. 3) C2
和C1差不多,但是数字有相同的#include <bits/stdc++.h>using namespace std;typedef long long ll;typedef unsigned long long ull;const int maxn=2e5+5;int a[maxn];std::vector<char> v;signed main()...原创 2019-04-30 20:58:49 · 91 阅读 · 0 评论 -
Codeforces Round #554 (Div. 2) D
#include <bits/stdc++.h>using namespace std;typedef long long ll;typedef unsigned long long ull;const int maxn=2e3+5;const int mod=1e9+7;int f[maxn][maxn],n;int main(){ cin>>n...原创 2019-04-30 20:58:58 · 185 阅读 · 0 评论 -
Codeforces Round #554 (Div. 2) C
#include<bits/stdc++.h>using namespace std;typedef long long ll;const int maxn=1e5+7;const int mod=1e9+7;int fac[maxn],tot=0;ll a,b;ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b);}vo...原创 2019-04-30 20:59:07 · 184 阅读 · 0 评论 -
Codeforces Round #554 (Div. 2) B
#include<bits/stdc++.h>using namespace std;typedef long long ll;const int maxn=2e5+7;int x,cnt,flag;queue<int>qu;int low(int x){ int cnt=0; int out=-1; while(x) { ...原创 2019-04-30 20:59:14 · 178 阅读 · 0 评论 -
Codeforces Round #554 (Div. 2) A
奇数和偶数去min相加就行了#include <bits/stdc++.h>using namespace std;typedef long long ll;const int maxn = 2e5+10;int a[maxn];int b[maxn];int main(){ int n,m;scanf("%d%d",&n,&m); int c...原创 2019-04-30 20:59:22 · 205 阅读 · 0 评论 -
Educational Codeforces Round 63 (Rated for Div. 2) D
dp[i][0] 表示之前不选的最大值,dp[i][1]表示选这个的最大值,dp[i][2]表示现在以后不选的最大值#include <bits/stdc++.h>using namespace std;typedef long long ll;const int maxn = 3e5+10;ll a[maxn], dp[maxn][5];int n,x;ll an...原创 2019-04-30 20:59:29 · 169 阅读 · 0 评论 -
Educational Codeforces Round 63 (Rated for Div. 2) C
#include <bits/stdc++.h>using namespace std;typedef long long ll;const int maxn =3e5+10;const int INF=0x3f3f3f3f;ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b);}int n,m;ll a[maxn];ll x[m...原创 2019-04-30 20:59:35 · 194 阅读 · 0 评论 -
Educational Codeforces Round 63 (Rated for Div. 2) B
数8的个数#include <bits/stdc++.h>using namespace std;typedef long long ll;const int maxn =1e5+10;const int INF=0x3f3f3f3f;char s[maxn];int main(int argc, char const *argv[]){ int n;scanf...原创 2019-04-30 20:59:42 · 205 阅读 · 0 评论 -
Codeforces Round #555 (Div. 3) A
f(x)为 x+1 这个数去掉后缀0的数,给出n,问经过无数次这种变换后,最多能得到多少个不同的数。#include <bits/stdc++.h>using namespace std;int check(int x){ x++; while(x!=1&&(!(x%10))) x/=10; return x;}int main...原创 2019-04-29 17:02:32 · 104 阅读 · 0 评论 -
Codeforces Round #541 (Div. 2) F Asya And Kittens
题意给你n-1对,相邻的在一块,选了这两个数,这两个集合就可以看成一个集合了,问符合条件的序列。很容易想到并查集的合并操作,对于一次合并相当于把两个集合变成了一块#include<ext/rope>库中 有个rope 算是一个可持久化数组,支持插入删除操作,并且支持+=-运算符内部采用分块链表实现,复杂度基本sqrt(n) #include<bits/s...原创 2019-02-25 17:51:03 · 160 阅读 · 0 评论 -
Codeforces Round#525(Div.2)Ehab and a component choosing problem CodeForces - 1088E
题意:有一个拥有 n 个节点的树,你要选 k 个联通块出来,使得这 k 个联通块中所有点的权值总和 sum 与联通块个数 k 的比值最大,多解时应使联通块的数量尽可能地多#include<stdio.h>#include<iostream>#include<algorithm>#include<cmath>#include<...原创 2018-12-05 20:08:29 · 202 阅读 · 1 评论 -
Codeforces Round#525(Div.2)Ehab and subtraction CodeForces - 1088B
题意:给你n个数,有k次操作,每次操作为:输出最小的正数,从数组的所有非零元素中减去它。如果只有0,就输出0我的做法是,先sort一下,定义一个变量p,判断下标最小的元素减去p是否大于0,大于就输出,不大于就下标++,继续判断。p是一个累加变量,每次都加上输出的那个元素。#include<stdio.h>#include<iostream>#inclu...原创 2018-12-05 19:19:04 · 115 阅读 · 0 评论 -
Codeforces Round #525 (Div. 2) Ehab and another construction problem CodeForces - 1088A
按照题意来说,答案应该不唯一,所以直接暴力写就行了,不用想太多#include<stdio.h>#include<iostream>#include<algorithm>#include<cmath>#include<cstring>#include<string.h>#include<queue>原创 2018-12-05 17:33:23 · 171 阅读 · 0 评论 -
Lyft Level 5 Challenge 2018 - Elimination Round 题解
A题:女王棋子将棋盘划分为四个象限,判断两个棋子的坐标是否在同一象限即可#include<stdio.h>#include<iostream>#include<algorithm>#include<cmath>#include<cstring>#include<queue>#include<stac...原创 2018-10-08 22:14:03 · 221 阅读 · 0 评论 -
Codeforces Round #511 (Div. 2)
A题:给一个数,把这个数分解为三个不是3的倍数有很多解,可以随意构造#include <bits/stdc++.h>using namespace std;int main(){ int n;cin>>n; if((n-2)%3==0) cout<<"1 2 "<<n-3; else cout<<"1 1 &q原创 2018-09-24 21:17:15 · 162 阅读 · 0 评论 -
AIM Tech Round 5 (rated, Div. 1 + Div. 2)
题目链接A题:找B的中心。。。直接写#include<stdio.h>#include<iostream>#include<algorithm>#include<cmath>#include<cstring>#include<queue>#include<stack>#include&a原创 2018-08-28 15:12:44 · 194 阅读 · 0 评论 -
Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)
题目链接A题:#include<stdio.h>#include<iostream>#include<algorithm>#include<cmath>#include<cstring>#include<queue>#include<stack>#include<list&am原创 2018-08-18 13:49:45 · 128 阅读 · 0 评论 -
Codeforces Round #502 (in memory of Leopoldo Taravilse, Div. 1 + Div. 2)
A题:注意id号和sum和都要排序。sum相同时,对id排序 代码如下:#include<bits/stdc++.h>using namespace std;const double pi=acos(-1);struct stu { int sum; int id;}s[1005];int cmp(stu a, stu b) { if (a.sum ...原创 2018-08-09 09:40:53 · 118 阅读 · 0 评论 -
Codeforces Round #485 (Div. 2), problem: (C) Three displays
#include <bits/stdc++.h>using namespace std;typedef long long ll;#define MAX 2000000000int a[3010];int c[3010];int num[3010];int main(){ ios::sync_with_stdio(false); int n; ...原创 2018-08-02 21:25:27 · 206 阅读 · 0 评论 -
Codeforces Round#525(Div.2)Ehab and a 2-operation task CodeForces - 1088C
题意:给你一个有n个数的数组你有两种操作: 将区间[1,i] 中所有的数字都加上x 将区间[1,i] 中所有的数字都对x 取模问能否在n+1步之内将这个序列变成一个严格递增的序列。随便取一个大于n的模数,比如说mod=n+1 也就是对于第i个数来说,让其变为k⋅mod+i,这样在进行了n 次修改之后,第n+1 次修改我进行一次取模操作,第i 个数就会变为i 了。...原创 2018-12-05 20:29:51 · 107 阅读 · 0 评论 -
Codeforces Round #524 (Div. 2) Petya and Origami CodeForces - 1080A
很简单的题意。。。#include<stdio.h>#include<iostream>#include<algorithm>#include<cmath>#include<cstring>#include<string.h>#include<queue>#include<stac原创 2018-12-05 21:35:17 · 233 阅读 · 0 评论 -
Codeforces Round #529 (Div. 3)
A题:很简单的一个题,直接按顺序输出这个字符串0,1,3,6......位置的字符就行了#include<stdio.h>#include<iostream>#include<algorithm>#include<cmath>#include<cstring>#include<string.h>#incl...原创 2019-01-13 14:05:06 · 89 阅读 · 0 评论 -
Codeforces Round #526 (Div. 2) CodeForces - 1084C
C题#include<stdio.h>#include<iostream>#include<algorithm>#include<cmath>#include<cstring>#include<string.h>#include<queue>#include<stack&g原创 2018-12-11 23:43:52 · 146 阅读 · 0 评论 -
Codeforces Round #526 (Div. 2) CodeForces - 1084A
A题#include<stdio.h>#include<iostream>#include<algorithm>#include<cmath>#include<cstring>#include<string.h>#include<queue>#include<stack&g原创 2018-12-11 22:57:49 · 190 阅读 · 0 评论 -
CodeForces - 1090M
题意:给一个n,有k种颜色接着有n个数,每个数代表一个颜色。问你最长相邻颜色不同的区间长度是多长复杂度 On#include<stdio.h>#include<iostream>#include<algorithm>#include<cmath>#include<cstring>#include<stri...原创 2018-12-17 18:14:47 · 253 阅读 · 0 评论 -
Educational Codeforces Round 56 (Rated for Div. 2) CodeForces - 1093C
题意:有一个序列a ,有n个数给出一个序列b,且满足 bi=ai+an−i+1 求序列a,答案不唯一,满足就行#include<stdio.h>#include<iostream>#include<algorithm>#include<cmath>#include<cstring>#include<...原创 2018-12-16 21:24:18 · 129 阅读 · 0 评论 -
Educational Codeforces Round 56 (Rated for Div. 2) CodeForces - 1093B
题意:给你一个字符串,任意变化,使它变成不是回文串,如果不行,就输出-1我的做法是,如果这个串只有同一个字母,那么直接输出-1否则,sort一下,输出就行了,即可保证不是回文串#include<stdio.h>#include<iostream>#include<algorithm>#include<cmath>#inclu...原创 2018-12-16 21:08:17 · 64 阅读 · 0 评论