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…
传送门 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…
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…
题目链接 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…
[题目链接] 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…
非常水的手速赛,大部分题都是没有算法的.巨慢手速,老年思维.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…
ACM International Collegiate Programming Contest World Finals 2014 A - Baggage 题目描述:有\(2n\)个字符摆在编号为\(1\)~\(2n\)格子里,奇数位为\(B\),偶数位为\(A\),另外编号为\((-2n+1)\)~\(0\)的格子是空的,现在可以移动两个相邻的字符,移动到两个空的格子里,最终使得全部\(A\)在全部\(B\)的左边,而且字符都是连续的,但不必放回原位,输出最小步数的方案. solution…
ACM International Collegiate Programming Contest World Finals 2013 A - Self-Assembly 题目描述:给出\(n\)个正方形组件,正方形每条边有一个标签,标签可能是00,表示这条边不能与其它边相拼,也可能是一个字母加正号或负号,相同字母不同符号的边可以相拼.每个组件有无限个,问利用这些组件是否能拼出一个无限大的多边形. solution 拆点,每个正方形拆成\(4\)个点,每条边一个,然后每条边拆成两个点(出点和入点)…
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…
ACM International Collegiate Programming Contest, Tishreen Collegiate Programming Contest (2017)- K. Poor Ramzi -dp+记忆化搜索 [Problem Description] 给你一串\(01\)字符串,将其划分,使得划分后,分别求出每组\(01\)之和后是回文的,求划分的方案数, [Solution] 定义\(dp[l][r]\)表示,区间\([l,r]\)中满足条件的方案数是多少.…
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…
Solution A:Careful Thief 题意:给出n个区间,每个区间的每个位置的权值都是v,然后找长度为k的区间,使得这个区间的所有位置的权值加起来最大,输出最大权值, 所有区间不重叠 思路:贪心的想法,长度为k的区间的起始点肯定是某个区间的起始点,或者长度为k的区间的结束点肯定是某个区间的结束点. 因为存在最优的答案,它的起点不在某个区间的起点,那么只有两种情况. 1° 不属于任何已知区间 2° 在某个已知区间的内部 首先考虑第一种情况  如果不属于任何已知区间,那么根据贪心,我肯定…
题意:有\(n\)个点,\(n-1\)条边,每条边正向和反向有两个权值,且每条边最多只能走两次,有\(m\)次询问,问你从\(u\)走到\(v\)的最大权值是多少. 题解:可以先在纸上画一画,不难发现,除了从\(u\)走到\(v\)的路径上的反向权值我们取不到,其他所有边的正反权值均能取到,所以答案就是:\(sum-u->v路径的反向权值\),问题也就转换成了求\(v->u\)的权值,那么这里我们就可以用LCA来求了. 首先,令一个点为根节点,然后求出\(v\)到根节点的距离和根节点到\(u\…
Kuma Rider久违的第二场训练,这场很水,又在vj的榜单上看到第一场的大哥了,2小时ak,大哥牛啤! A.水 #include<cstdio> #include<iostream> #include<algorithm> #include<queue> #include<cstring> #include<string> #include<vector> #include<cmath> #include&…
省选考前单挑做点ACM练练细节还是很不错的嘛- 福利:http://codeforces.com/gym/101350 先来放上惨不忍睹的virtual participate成绩(中间跑去食堂吃饭于是浪费了一点时间) Problem A DNF Problem B 1Y(5min) Problem C 1Y(37min) Problem D 2Y(9min) Problem E 4Y(3h58min) Problem F DNF Problem G 1Y(4h13min) Problem H…
F. Palindrome Problem Description A string is palindrome if it can be read the same way in either direction, for example "maram" is palindrome, while "ammar" is not. You are given a string of n characters, where each character is eithe…
题目链接:https://vjudge.net/contest/154238#overview. ABCDE都是水题. F题,一开始分类讨论,结果似乎写挫了,WA了一发.果断换并查集上,A了. G题,状态压缩DP,不难写,但是时限有点紧,读入也比较恶心..值得注意的是计算一个数二进制下有几个1可以用__builtin_popcount(mask):判断a和b在二进制表示下a是不是b的子集可以用(a&b)==a:另外字符串s想移除最后一位可以s.resize(s.size()-1)或者s.eras…
A. My Friend of Misery 计算出答案的上下界即可. 时间复杂度$O(n)$. #include<bits/stdc++.h> using namespace std; const int N=100010; typedef long long LL; int main(){ int _;scanf("%d",&_); while(_--){ int n;scanf("%d",&n); LL cur=0,r=1LL<…
今日份的训练题解,今天写出来的题没有昨天多,可能是因为有些事吧... Gym100814B 这个题就是老师改卷子,忘带标准答案了,但是他改了一部分卷子,并且确定自己改的卷子没出错,他想从改过的卷子里把标准答案推出来. 因为是选择题,答案就是A,B,C,D里的一个,如果A,B,C,都不对,那就是D对.如果不确定就是?,就是这样的题目. 一开始写的忘记判断如果三个选项都不对,那么剩下的就是答案这个了... 代码写的很丑,想不到简单的写法... 代码: #include<iostream> #inc…
A. Chrome Tabs 当$n=1$时答案为$0$,当$k=1$或$k=n$时答案为$1$,否则答案为$2$. #include<cstdio> int T,n,k; int main(){ freopen("tabs.in","r",stdin); scanf("%d",&T); while(T--){ scanf("%d%d",&n,&k); if(n==1)puts("…
先说一个简单的题目(题目大意自己看去,反正中文):hihocoder上的:http://hihocoder.com/problemset/problem/1476 然后因为这个n和m的矩阵范围是1000,所以比较简单 然后我们说一下hihocoder上面的做法,首先,这题的做法是http://www.cnblogs.com/heimao5027/p/6738715.html的简化版本,因为颜色只有两种,所以和前面链接给的做法那样,用单调栈维护一下即可. //看看会不会爆int!数组会不会少了一维…
题目链接:http://codeforces.com/gym/101350/problem/E 题目大意:给你一个长度为n的方格,方格上面都被染色成了白色.每次染色都是选择白色的,假设目前选择的这块白色(白色联通块)的长度为L,每次都只能选择<=(L+1)/2的素数染色.问谁赢? 思路:果然博弈不会啊,感谢这位神牛:链接 当n=2||n=3先手必败 其余的n必胜,n=1就不解释了.当n>=4的时候,如果是奇数,那么每次都取出中间两个,如果是偶数,每次都取出中间三个,然后对称取即可. //看看会…
题目链接: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…
A.Sherlock Bones 题意: 给出长度为n的01串,问f(i,j)=f(j,k),(i<j<k)的i,j,k取值种数.其中f(i,j)表示[i,j]内1的个数, 且s[j]必须为1. 先把串看出是一串1两两之间穿插若干个0的联通块,不妨设block[i]为联通块i里面0的个数. 先考虑i,k处都为0的情况. 枚举i在哪个联通块里面.再枚举j,由于对称性,此时k在block[i+1],block[i+3],block[i+5]...内,那么此时方法数为block[i]*(block[…
http://codeforces.com/gym/100676/attachments 题目大意: 有n个城市,有m条路,每条路都有边长,如果某几个城市的路能组成一个环,那么在环中的这些城市就有传送门,能够瞬间抵达对方的城市(即距离为0),否则,就要走这条路,并且经过的路程为这条路的长度. 问,找一个城市作为这些城市的首都 要求:除了首都城市外,其他城市到首都的最大距离最短. 思路: 边双连通缩点以后就是一棵树,找树上的直径,首都一定是直径上的点.(orz,自己明明注意到了一定是直径上面的点,…
A.Arcade Game(康拓展开) 题意: 给出一个每个数位都不同的数n,进行一场游戏.每次游戏将n个数的每个数位重组.如果重组后的数比原来的数大则继续游戏,否则算输.如果重组后的数是最大的数则算赢,问赢的概率. 题解: 用康拓展开求出n是第几大的数,然后递推后面的概率. #include <bits/stdc++.h> using namespace std; typedef long long ll; int t; ]; double ans; ] = {, , , , , , , ,…