Codeforces Round #533 (Div. 2) Solution】的更多相关文章

A. Salem and Sticks 签. #include <bits/stdc++.h> using namespace std; #define N 1010 int n, a[N]; int work(int x) { ; ; i <= n; ++i) res += max(, abs(x - a[i]) - ); return res; } int main() { while (scanf("%d", &n) != EOF) { ; i <…
link orz olinr AK Codeforces Round #533 (Div. 2) 中文水平和英文水平都太渣..翻译不准确见谅 T1.给定n<=1000个整数,你需要钦定一个值t,使得每个整数到线段[t-1,t+1]距离和最小,求最小距离,每个数<=100 枚举t #include <cstdio> using namespace std; int n, a[1010]; int main() { scanf("%d", &n); for…
从这里开始 题目列表 小结 Problem A Points on the line Problem B Our Tanya is Crying Out Loud Problem C Phone Numbers Problem D Alena And The Heater Problem E Cashback Problem F Machine Learning 小结 这场比赛和同学一起打.本来应该是很开心的事情,结果留下好多遗憾. 第一个遗憾是没能在20分钟内消灭A.B题.然后分数就不是很可观…
对没错下面的代码全部是python 3(除了E的那个multiset) 题目链接:https://codeforces.com/contest/1157 A. Reachable Numbers 按位算贡献,一位数的贡献直接算即可 n=int(input()) ans=0 while (n>=10): tmp=n%10 tmp=10-tmp ans+=tmp n+=tmp while (n>0) and (n%10==0): n//=10 ans+=9 print(ans) B. Long N…
人生第一场Div. 1 结果因为想D想太久不晓得Floyd判环法.C不会拆点.E想了个奇奇怪怪的set+堆+一堆乱七八糟的标记的贼难写的做法滚粗了qwq靠手速上分qwqqq A. Skyscrapers 将行列各自离散化并记录下每一个值在行离散化时和列离散化时得到的值以及每一行.每一列出现的最大离散化值 对于每一行和每一列考虑其相交格子的两个离散化值,如果它们的差为\(\Delta\),就把它对应行列最大离散化值中较小的+\(\Delta\),最后两者取Max #include<iostream…
题目链接:https://codeforces.com/contest/1105 C. Ayoub and Lost Array 题目大意:一个长度为n的数组,数组的元素都在[L,R]之间,并且数组全部元素的和可以被3整除,问有多少种方法构建出该数组.答案模1000000007 例 输入 2 1 3 输出 3 note:满足的情况只有[1,2],[2,1],[3,3] 解题思路:用dp[i][j]表示长度为i的数组,元素大小在[L,R]之间,并且元素和模3的余数为j的方案数,我们可以计算出[L,…
从这里开始 题目地址 瞎扯 Problem A Piles With Stones Problem B And Problem C Photo of The Sky Problem D Chemical table Problem E Hills Problem F AB-Strings 瞎扯 打比赛,发现自己越来越菜. 差点C题都不会了,怀疑人生... 发现自己C的贪心挂了两次然后D题不会怀疑不应来打这场比赛. 然后看到E.出题人的仁慈啊..终于不考智商了.提高组的送分dp(好吧,应该是省选里…
传送门:http://codeforces.com/contest/1105/problem/C C. Ayoub and Lost Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Ayoub had an array aa of integers of size nn and this array had two…
传送门:http://codeforces.com/contest/1105/problem/B B. Zuhair and Strings time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Given a string ss of length nn and integer kk (1≤k≤n1≤k≤n). The string…
链接:https://codeforces.com/contest/1105/problem/C 题意: 给n,l,r. 一个n长的数组每个位置可以填区间l-r的值. 有多少种填法,使得数组每个位置相加的和是3的倍数 思路: 赛后看代码都看不懂的题. dp, 从1个数组扩展到n个数组, dp[i][j]是加上第i个数组后,分别余0,1,2的个数. 余0则是,i-1余0*自己余0+(i-1余1*自己余2)+(i-1余2*自己余1) 剩下同理 代码: #include <bits/stdc++.h>…
链接:https://codeforces.com/contest/1105/problem/D 题意: 给n*m的地图,最多9个人,同时有每个人的扩张次数(我开始以为是直线扩张最大长度..实际是能连续扩张次数.) 地图上有‘#’,‘.',和数字,数字对应每个人的据点, 从1-n轮流扩张. 地图被扩张完后,输入每个人的据点数目. 思路: 赛后写的题.还一堆bug, 用队列和一个数组,记录每个人能扩张的点和下一次能扩张的个数. 然后就是一堆循环套着.每次入队更新下一次的扩张个数,同时用flag记录…
链接:https://codeforces.com/contest/1105/problem/B 题意: 给一个字符串和k,连续k个相同的字符,可使等级x加1, 例:8 2 aaacaabb 则有aa aa 即x=2. 求最大的k 思路: 第一眼想的是诶个查找,但是绝对会T,就没做,过一个小时才想到可以直接遍历,记录每个字符对应的最大x即可. 代码: #include <bits/stdc++.h> using namespace std; const int MAXN = 200000+10…
链接:https://codeforces.com/contest/1105/problem/A 题意: 给n个数,找到一个数t使i(1-n)∑|ai-t| 最小. ai-t 差距1 以内都满足 思路: 暴力,枚举. 代码: #include <bits/stdc++.h> using namespace std; typedef long long LL; const int MAXN = 1000+5; int a[MAXN]; int main() { int n; scanf(&quo…
从这里开始 比赛目录 我又不太会 div 1 A? 我菜爆了... Problem A Cut and Paste 暴力模拟一下. Code #include <bits/stdc++.h> using namespace std; typedef bool boolean; const int N = 1e6 + 5; const int Mod = 1e9 + 7; int T; int x; int len; char s[N]; int paste(int s1, int t1, in…
题目链接:https://codeforces.com/contest/1105/problem/E 题意:有 n 个事件,op = 1 表示我可以修改昵称,op = 2 表示一个名为 s_i 的朋友查询我当前的名字.一个朋友是高兴的当且仅当他每次查询我的名字都为 s_i,保证每个朋友至少查询一次我的名字,问最多可以有多少个朋友高兴. 题解:在我两次修改昵称之间,若出现不同的朋友,则他们是互斥的,可以在他们之间连一条边,然后求图的最大独立集,而原图的最大独立集等于补图的最大团,所以求补图的最大团…
题目链接:https://codeforces.com/contest/1105/problem/D 题意:p 个人在 n * m 的地图上扩展自己的城堡范围,每次最多走 a_i 步(曼哈顿距离),按 1 ~ p 的顺序,问最后每个人占领的点的数量. 题解:用一个队列维护当前起点,用另一个队列模拟当前起点走 a_i 步可以到达的全部点.(60 ~ 63行关键代码,多源bfs,不可分开跑) 数据: 4 3 2 2 1 1.. 1.. ..2 ... output:10 2 #include <bi…
Problem A Hotelier 直接模拟即可~~ 复杂度是$O(10 \times n)$ # include<bits/stdc++.h> using namespace std; ; char s[N]; ]; int main() { int n; scanf("%d",&n); scanf("%s",s); ;i<n;i++) { if (s[i]=='L') { ;j<=;j++) if (!a[j]) { a[j]=…
A. Salem and Sticks time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Salem gave you nn sticks with integer positive lengths a1,a2,…,ana1,a2,…,an. For every stick, you can change its length t…
A. Ehab and another construction problem Water. #include <bits/stdc++.h> using namespace std; int x; int main() { while (scanf("%d", &x) != EOF) { , b = -; ; i <= x && a == - && b == -; ++i) { for (int j = i; j <=…
E - Helping Hiasat 裸的最大团,写了一种 2 ^ (m / 2)  * (m / 2)的复杂度的壮压, 应该还有更好的方法. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PLL pair<LL, LL> #define PLI pair<LL, int> #define PII p…
C: 题意: 有n个整数ai,数列a有两个神奇的性质.1.所有的整数都在[l,r]范围内.2.这n个数的和能被3整除.现在给出l和r,和个数n,问你有多少种方法构造出数列a,方案数mod1e9+7. 题解: 一个数被3除只有三种可能.1.整除,2.余1,2.余2. 然后我们再想这个问题,[l,r]区间内,能被3整除的数有多少?a0=r/3-l/3.余1/2的数有多少?a1/2=((r-l+1)-a0)/2.(这里具体余1和余2不重要,想想为什么) 我们设f[i][j]为前i个数,和除3余j的方案…
A. A Prank Solved. 题意: 给出一串数字,每个数字的范围是$[1, 1000]$,并且这个序列是递增的,求最多擦除掉多少个数字,使得别人一看就知道缺的数字是什么. 思路: 显然,如果缺的这块数字的个数刚好等于右界 - 左界 + 1 那么就可以知道 还需要考虑数据范围,因为是$<= 1000  和 >= 1$ 那么对于两边的边界需要特殊考虑. #include <bits/stdc++.h> using namespace std; #define N 110 in…
A. Coins Water. #include <bits/stdc++.h> using namespace std; int n, s; int main() { while (scanf("%d%d", &n, &s) != EOF) { ; ; --i) while (s >= i) { ++res; s -= i; } printf("%d\n", res); } ; } B. Views Matter Solved.…
A. Petya and Origami Water. #include <bits/stdc++.h> using namespace std; #define ll long long ll n, k; ll Get(ll x) { ? (x * n) / k : (x * n) / k + ; } int main() { while (scanf("%lld%lld", &n, &k) != EOF) { ll res = Get() + Get()…
A. The Fair Nut and Elevator Solved. 签. #include <bits/stdc++.h> using namespace std; #define N 110 int n, a[N]; int main() { while (scanf("%d", &n) != EOF) { ; i <= n; ++i) scanf("%d", a + i); int res = 1e9; , tmp = ; x &…
A. Snowball 签. #include <bits/stdc++.h> using namespace std; ], d[]; int main() { while (scanf("%d%d", &w, &h) != EOF) { ; i < ; ++i) scanf("%d%d", u + i, d + i); ; --i) { w += i; ; j < ; ++j) if (i == d[j]) { w -=…
A. Roman and Browser 签到. #include <bits/stdc++.h> using namespace std; ]; int get(int b) { ]; memset(vis, , sizeof vis); int c = b; while (c <= n) { vis[c] = ; c += k; } c = b - k; ) { vis[c] = ; c -= k; } , r = ; ; i <= n; ++i) if (!vis[i]) {…
A. Splitting into digits Solved. #include <bits/stdc++.h> using namespace std; int n; void solve() { printf("%d\n", n); ; i <= n; ++i) printf(, " \n"[i == n]); } int main() { while (scanf("%d", &n) != EOF) solve(…
传送门 A.The Doors 看懂题目就会写的题 给一个 $01$ 序列,找到最早的位置使得 $0$ 或 $1$ 已经全部出现 #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> using namespace std; typedef long long ll; inline int read() { ,f=; ch…
A. Salem and Sticks 题目描述 Salem gave you n n n sticks with integer positive lengths a1,a2,…,an a_1, a_2, \ldots, a_n a1​,a2​,…,an​ . For every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it)…