Solution A:Careful Thief 题意:给出n个区间,每个区间的每个位置的权值都是v,然后找长度为k的区间,使得这个区间的所有位置的权值加起来最大,输出最大权值, 所有区间不重叠 思路:贪心的想法,长度为k的区间的起始点肯定是某个区间的起始点,或者长度为k的区间的结束点肯定是某个区间的结束点. 因为存在最优的答案,它的起点不在某个区间的起点,那么只有两种情况. 1° 不属于任何已知区间 2° 在某个已知区间的内部 首先考虑第一种情况  如果不属于任何已知区间,那么根据贪心,我肯定…
A:Zero Array 题意:两种操作, 1 p v  将第p个位置的值改成v  2  查询最少的操作数使得所有数都变为0  操作为可以从原序列中选一个非0的数使得所有非0的数减去它,并且所有数不能变为负数 思路:考虑第二种操作,显然,最少的操作数肯定是不同数的个数 用map 记录,特殊注意0的存在 #include <bits/stdc++.h> using namespace std; #define N 100010 unordered_map <int, int> mp;…
A:Martadella Stikes Again 水. #include <bits/stdc++.h> using namespace std; #define ll long long int t; ll R, r; int main() { scanf("%d", &t); while (t--) { scanf("%lld%lld", &R, &r); if (R * R > 2ll * r * r) puts(&…
https://codeforces.com/gym/101810 A. Careful Thief time limit per test 2.5 s memory limit per test 256 MB input standard input output standard output There are consecutive buildings numbered from 1 to 109 each of which has an amount of money in it. T…
题意:有\(n\)个点,\(n-1\)条边,每条边正向和反向有两个权值,且每条边最多只能走两次,有\(m\)次询问,问你从\(u\)走到\(v\)的最大权值是多少. 题解:可以先在纸上画一画,不难发现,除了从\(u\)走到\(v\)的路径上的反向权值我们取不到,其他所有边的正反权值均能取到,所以答案就是:\(sum-u->v路径的反向权值\),问题也就转换成了求\(v->u\)的权值,那么这里我们就可以用LCA来求了. 首先,令一个点为根节点,然后求出\(v\)到根节点的距离和根节点到\(u\…
ACM International Collegiate Programming Contest, Tishreen Collegiate Programming Contest (2018) Syria, Lattakia, Tishreen University, April, 30, 2018 Problem A. Can Shahhoud Solve it? Problem B. Defeat the Monsters Problem C. UCL Game Night Problem…
Battle Royale games are the current trend in video games and Gamers Concealed Punching Circles (GCPC) is the most popular game of them all. The game takes place in an area that, for the sake of simplicity, can be thought of as a two-dimensional plane…
Solved A Gym 100712A Who Is The Winner Solved B Gym 100712B Rock-Paper-Scissors Solved C Gym 100712C Street Lamps Solved D Gym 100712D Alternating Strings Solved E Gym 100712E Epic Professor Solved F Gym 100712F Travelling Salesman Solved G Gym 10071…
John loves winter. Every skiing season he goes heli-skiing with his friends. To do so, they rent a helicopter that flies them directly to any mountain in the Alps. From there they follow the picturesque slopes through the untouched snow. Of course th…
题目链接 https://vjudge.net/contest/240074#overview 只写一下自己做的几个题吧 /* D n^2的暴力dp怎么搞都可以的 这里先预处理 i到j的串时候合法 转移的时候枚举上一个状态 O1判断 */ #include<cstdio> #include<cstring> #include<iostream> #define maxn 1010 using namespace std; int T,n,m,f[maxn],g[maxn…
目录 注意!!此题解存在大量假算法,请各位巨佬明辨! Problem A Digits Are Not Just Characters 题面 题意 思路 代码 Problem B Arithmetic Progressions 题面 代码 Problem C Emergency Evacuation 题意 题解 代码 Problem D Shortest Common Non-Subsequence 题面 代码 Problem E Eulerian Flight Tour Problem G W…
传送门 Description Using at most 7 matchsticks, you can draw any of the 10 digits as in the following picture: The picture shows how many sticks you need to draw each of the digits. Zaytoonah has a number that consists of N digits. She wants to move som…
传送门 Description Hasan and Bahosain want to buy a new video game, they want to share the expenses. Hasan has a set of N coins and Bahosain has a set of M coins. The video game costs W JDs. Find the number of ways in which they can pay exactly W JDs su…
A - Coins Time Limit:3000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Description standard input/output Hasan and Bahosain want to buy a new video game, they want to share the expenses. Hasan has a set of N coins and Bahosain has a…
Rectangles time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standard output Given an R×C grid with each cell containing an integer, find the number of subrectangles in this grid that contain only one disti…
[题目链接] A - Who Is The Winner 模拟. #include <bits/stdc++.h> using namespace std; int T; int n; struct X { string name; int num; int ti; }s[10010]; bool cmp(X&a,X&b){ if(a.num != b.num) return a.num > b.num; return a.ti < b.ti; } int main…
[题目链接] A - Watching TV 模拟.统计一下哪个数字最多即可. #include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int T, n; char s[maxn]; int a[maxn]; int main() { scanf("%d", &T); while(T --) { scanf("%d", &n); memset(a,…
A - Watching TV /* 题意:求出出现次数最多的数字 */ #include <cstdio> #include <algorithm> #include <cstring> using namespace std; int T,n,a[100010]; char s[110]; int main(){ scanf("%d",&T); while(T--){ memset(a, 0, sizeof(a)); scanf(&quo…
题目链接:https://codeforces.com/gym/101853 A: ✅ B: (二分图匹配) https://blog.csdn.net/qq_41997978/article/details/89165151(二分图匹配+基础数论+算术分解建图) C: (逆序对) 已过 D:✅ E:✅ https://blog.csdn.net/Link_Ray/article/details/89102023 (状压经典题) F:✅ G: 已过 https://blog.csdn.net/L…
非常水的手速赛,大部分题都是没有算法的.巨慢手速,老年思维.2个小时的时候看了下榜,和正常人差了3题(,最后还没写完跑去吃饭了.. A 水 Sort 比大小 /** @Date : 2017-09-01 12:32:08 * @FileName: A.cpp * @Platform: Windows * @Author : Lweleth (SoungEarlf@gmail.com) * @Link : https://github.com/ * @Version : $Id$ */ #incl…
bryce1010模板 http://codeforces.com/gym/101810 #include <bits/stdc++.h> using namespace std; #define ll long long const int MAXN=1010; int a[MAXN<<1]; int main() { int t; cin>>t; int n; while(t--) { cin>>n; for(int i=1;i<=2*n;i++)…
bryce1010模板 http://codeforces.com/gym/101810 #include<bits/stdc++.h> using namespace std; #define ll long long ll a[1000005]; int main() { int t,n,temp; ll ans,maxn,minl,x; scanf("%d",&t); while(t--) { scanf("%I64d",&n);…
bryce1010模板 http://codeforces.com/gym/101810 #include<bits/stdc++.h> using namespace std; #define ll long long const ll maxn = 1e5 + 5; const ll mod = 1e9+7; ll n; ll p[maxn]; ll vis[maxn]; int main() { ll t; scanf("%lld",&t); ll pre;…
bryce1010模板 http://codeforces.com/gym/101810 #include <bits/stdc++.h> using namespace std; #define ll long long int main() { int t; scanf("%d",&t); ll n,m; while(t--) { scanf("%lld%lld",&n,&m); ll cnt=0; if(m>n)swa…
bryce1010模板 http://codeforces.com/gym/101810 #include <bits/stdc++.h> using namespace std; #define ll long long ll lowbit(ll x) { return x&(-x); } int main() { ll t; cin>>t; ll x; while(t--) { cin>>x; ll res=1; while((x&1)==0) {…
bryce1010模板 http://codeforces.com/gym/101810 #include <bits/stdc++.h> using namespace std; #define ll long long int main() { int T; cin >> T; while (T--) { ll n, x; cin >> x >> n; if (n == 1) { cout << x << endl; contin…
bryce1010模板 http://codeforces.com/gym/101810/problem/A 大模拟,写崩了,代码借队友的...... 注意处理段与段的连接问题: #include<bits/stdc++.h> using namespace std; const int maxn=1e5+5; struct node{ long long l,r,val; node(){} node(long long ll,long long rr,long long vval) { l=…
题目链接https://nanti.jisuanke.com/t/28852 题目大意是 h*w 的平面,每两个点有且仅有一条路径,类似于封闭的联通空间,然后在这h*w个点中选取(标记为1~N)N个点(给了坐标),求从1号点按1~N的顺序走到N号点的路程. 练习赛的时候没有思路,队友说可以建树,但还是不清不楚没写出来. 做法是LCA. 将封闭的联通空间建树(点的位置与字符的位置有点麻烦),然后按顺序求两点的最近的公共祖先求深度得距离,最后得路程,算是一道LCA的模板. #include <bit…
// Coolest Ski Route #include <iostream> #include <cstdio> #include <cstring> #include <string> #include <algorithm> #include <utility> #include <vector> #include <map> #include <queue> #include <st…
题面 题意:T组数据,每次给你1e5个点的树(1为根),每个点有一权值,询问1-n每个节点的子树中, 至少修改几个点的权值(每次都可以任意修改),才能让子树中任意2点的距离==他们权值差的绝对值 无解输出-1 题解:画图不难发现,如果这个节点有3个儿子,也就是不包含它连向它父亲的边,它还有多于2条边的话,一定不行 因为子节点权值只能是这个节点+1或者-1,所以只能存在最多2个 那我们就又发现了,只有这个子树,可以拉成一个链的时候,才有答案, 考虑在链中的情况,如何判断修改最少的个数,使得这是个差…