- 博客(48)
- 资源 (3)
- 收藏
- 关注
原创 [AHOI2009]中国象棋
https://www.luogu.org/problemnew/show/P2051C++版本一数位DP变形棋子的顺序是无所谓的,并不需要准确知道当前棋盘的状态于是有了100分做法:dp[i][j][k]表示放了前i行,有j列是有1个棋子,有k列有两个棋子转移显然,分类讨论,乘法和加法原理,代码注释中写的很详细#include <iostream>#inc...
2019-02-28 22:44:19 211
原创 有线电视网
https://www.luogu.org/problemnew/show/P1273C++版本一树状DP我们设dp[i][j]表示在以i为根的子树中,满足j个客户的需求所能获得的最大收益,那么在最终求最多客户时,只要求最大的dp[1][i]>=0的i就行了。至于分组背包,我们设dp[i][u][j]表示以u为根的子树,仅用前i个儿子,满足j个客户取得最大价值,那么d...
2019-02-28 22:41:58 324
原创 拓扑排序(Topology_Sort)
基本思想对一个有向无环图(Directed Acyclic Graph简称DAG)G进行拓扑排序,是将G中所有顶点排成一个线性序列,使得图中任意一对顶点u和v,若边(u,v)∈E(G),则u在线性序列中出现在v之前。通常,这样的线性序列称为满足拓扑次序(Topological Order)的序列,简称拓扑序列。简单的说,由某个集合上的一个偏序得到该集合上的一个全序,这个操作称之为拓扑排序。...
2019-02-25 16:24:10 745
原创 Gourmet choice
https://codeforces.com/contest/1131/problem/D/**@Author: STZG*@Language: C++*/#include <bits/stdc++.h>#include<iostream>#include<algorithm>#include<cstdlib>#includ...
2019-02-25 15:52:22 264
原创 Toy Train
D1. Toy Train (Simplified)https://codeforces.com/contest/1130/problem/D1D2. Toy Trainhttps://codeforces.com/contest/1130/problem/D2题解:/**@Author: STZG*@Language: C++*/#include <bit...
2019-02-25 13:58:04 1294
原创 Connect
https://codeforces.com/contest/1130/problem/C题解:两遍BFS+暴力/**@Author: STZG*@Language: C++*/#include <bits/stdc++.h>#include<iostream>#include<algorithm>#include<cstdli...
2019-02-25 13:56:39 305
原创 Two Cakes
https://codeforces.com/contest/1130/problem/B题解:/**@Author: STZG*@Language: C++*/#include <bits/stdc++.h>#include<iostream>#include<algorithm>#include<cstdlib>#i...
2019-02-25 13:54:48 347
原创 Be Positive
https://codeforces.com/contest/1130/problem/A题解:只要统计原来的正负数量就行了,只要正负其中一个超过一半就行 /**@Author: STZG*@Language: C++*/#include <bits/stdc++.h>#include<iostream>#include<algorithm&...
2019-02-25 13:53:58 727
原创 Asya And Kittens
https://codeforces.com/contest/1131/problem/F题解:并查集+路径压缩+DFS+树/**@Author: STZG*@Language: C++*/#include <bits/stdc++.h>#include<iostream>#include<algorithm>#include<...
2019-02-24 14:42:37 357
原创 Birthday
https://codeforces.com/contest/1131/problem/C题解:/**@Author: STZG*@Language: C++*/#include <bits/stdc++.h>#include<iostream>#include<algorithm>#include<cstdlib>#i...
2019-02-24 09:12:10 354
原创 Draw!
https://codeforces.com/contest/1131/problem/B题解:/**@Author: STZG*@Language: C++*/#include <bits/stdc++.h>#include<iostream>#include<algorithm>#include<cstdlib>#i...
2019-02-24 09:11:19 215
原创 Sea Battle
https://codeforces.com/contest/1131/problem/A题解:简单题把周长加起来就完事了/**@Author: STZG*@Language: C++*/#include <bits/stdc++.h>#include<iostream>#include<algorithm>#include<...
2019-02-24 09:10:19 315
原创 Average Superhero Gang Power
https://codeforces.com/contest/1111/problem/B/**@Author: STZG*@Language: C++*/#include <bits/stdc++.h>#include<iostream>#include<algorithm>#include<cstdlib>#includ...
2019-02-06 11:08:47 395
原创 Superhero Transformation
https://codeforces.com/contest/1111/problem/AC++版本一题解:长度不同肯定不可以如果长度相同,那么暴力比较每一个是不是同属于元音或者辅音/**@Author: STZG*@Language: C++*/#include <bits/stdc++.h>#include<iostream>#incl...
2019-02-04 10:36:22 293
原创 Lunar New Year and a Wander
https://codeforces.com/contest/1106/problem/DC++版本一题解:每次都走曾经和现在可以选择的最小节点/**@Author: STZG*@Language: C++*/#include <bits/stdc++.h>#include<iostream>#include<algorithm>...
2019-02-04 10:17:56 287
原创 Lunar New Year and Number Division
https://codeforces.com/contest/1106/problem/CC++版本一题解:一定是两个两个相加且一个最大一个最小/**@Author: STZG*@Language: C++*/#include <bits/stdc++.h>#include<iostream>#include<algorithm>...
2019-02-04 10:17:50 445
原创 Lunar New Year and Food Ordering
https://codeforces.com/contest/1106/problem/BC++版本一题解:贪心按价格排序,作为不足时的取菜顺序,设一个指针记录,如果指针到n+1,说明没有菜可以取了/**@Author: STZG*@Language: C++*/#include <bits/stdc++.h>#include<iostream...
2019-02-04 10:17:44 288
原创 Lunar New Year and Cross Counting
https://codeforces.com/contest/1106/problem/AC++版本一题解:暴力模拟就行了/**@Author: STZG*@Language: C++*/#include <bits/stdc++.h>#include<iostream>#include<algorithm>#include&...
2019-02-04 10:17:38 457
原创 迷宫
https://ac.nowcoder.com/acm/contest/332/JC++版本一题解:BFS/**@Author: STZG*@Language: C++*/#include <bits/stdc++.h>#include<iostream>#include<algorithm>#include<cstdlib...
2019-02-03 10:03:15 243
原创 wzoi
https://ac.nowcoder.com/acm/contest/332/IC++版本一题解:如果相邻两个相同,那么肯定是看一题写一题,不相同就存储着我们可以得到类似于括号匹配的栈,就行匹配匹配成功的数量就是10分的数量,不成功的就是5分的/**@Author: STZG*@Language: C++*/#include <bits/stdc++....
2019-02-03 10:00:08 1147
原创 肥猪
https://ac.nowcoder.com/acm/contest/332/HC++版本一#include <map>#include <set>#include <ctime>#include <cmath>#include <queue>#include <stack>#include <v...
2019-02-03 09:56:52 504
原创 区间或和
https://ac.nowcoder.com/acm/contest/332/GC++版本一题解:暴力肯定超时如果【a,b】那么差值b-a的代表增量,这个增量的二进制位的多少代表【a,b】有几位二进制位有过变化,那么变化过的二进制位肯定是1./**@Author: STZG*@Language: C++*/#include <bits/stdc++.h&g...
2019-02-03 09:55:46 410
原创 石头剪刀布
https://ac.nowcoder.com/acm/contest/332/FC++版本一#include <map>#include <set>#include <ctime>#include <cmath>#include <queue>#include <stack>#include <v...
2019-02-03 09:51:00 251
原创 海啸
https://ac.nowcoder.com/acm/contest/332/EC++版本一题解:二维前缀和DPdp[i][j]代表从(1,1)到(i,j)的所有低于d的数量/**@Author: STZG*@Language: C++*/#include <bits/stdc++.h>#include<iostream>#include...
2019-02-03 09:49:57 306
原创 美食
https://ac.nowcoder.com/acm/contest/332/DC++版本一题解:从前往后,如果偶数那就自己两个两个取如果奇数那就和后面一个分别取一个一次,然后自己两个两个取如果奇数,后面的不存在那就两个两个,留下一个剩下来/**@Author: STZG*@Language: C++*/#include <bits/stdc++.h&...
2019-02-03 09:47:26 436
原创 项链
https://ac.nowcoder.com/acm/contest/332/CC++版本一题解:贪心按价值排序,从大到小取,取足为止/**@Author: STZG*@Language: C++*/#include <bits/stdc++.h>#include<iostream>#include<algorithm>...
2019-02-03 09:44:46 285 1
原创 煤气灶
https://ac.nowcoder.com/acm/contest/332/BC++版本一题解:二分 /**@Author: STZG*@Language: C++*/#include <bits/stdc++.h>#include<iostream>#include<algorithm>#include<cst...
2019-02-03 09:42:48 292
原创 出题
https://ac.nowcoder.com/acm/contest/332/AC++版本一题解:不能大于全部九的情况,小于全部六的情况/**@Author: STZG*@Language: C++*/#include <bits/stdc++.h>#include<iostream>#include<algorithm>#...
2019-02-03 09:41:09 294
原创 炫酷数学
https://ac.nowcoder.com/acm/contest/331/JC++版本一题解:考虑每一位,只有在(0,0)(0,1)(1,0)的三种情况时满足条件。根据乘法原理,答案即为3^M#include <bits/stdc++.h>using namespace std;typedef long long ll; const int mod ...
2019-02-02 10:05:53 297
原创 炫酷镜子
https://ac.nowcoder.com/acm/contest/331/IC++版本一std题解:注意到固定转向的镜子没有办法汇聚,也就没有办法卡掉模拟光线。直接模拟即可,或者使用并查集或者记忆化搜索也可。时间复杂度O(NM)#include <bits/stdc++.h> using namespace std; //为了更好的扩展性,这...
2019-02-02 10:03:42 317
原创 炫酷雪花
https://ac.nowcoder.com/acm/contest/331/H 题解:std #include <bits/stdc++.h>using namespace std;typedef long long ll; const int mn = 5005; int n;ll k;int a[mn];char s[mn]; s...
2019-02-02 10:01:19 346
原创 炫酷数字
https://ac.nowcoder.com/acm/contest/331/GC++版本一std题解:#include <bits/stdc++.h>using namespace std; const int N = 1e6 + 5;int min_num[N], T, n;int fact_count[N];int main() { m...
2019-02-02 09:58:59 540
原创 炫酷回文
https://ac.nowcoder.com/acm/contest/331/F题解:std引理:如果一个子矩形的字符串可以单独重组成为回文串,那么其出现奇数个的字符至多只有一个。考虑状压数字的每一位,第i位为1表示i出现次数为奇数次。基于上面的引理,我们可以从左到右维护矩形前缀异或和。当子矩形异或和的二进制表示只有1个或者0个1位时,该子矩形能单独重组成为回文串。具...
2019-02-02 09:55:53 227 1
原创 炫酷划线
https://ac.nowcoder.com/acm/contest/331/EC++版本一题解:std题意转化为:读入一些区间,输出直到有区间交叉的第一个位置。正经解法:考虑线段树维护最小值。将左端点值赋值在右端点下标,查询左闭右开内最小值是否小于左端点。随意解法:树状数组哈希即可,具体的做法是对于每次连线,随机一个足够随机的值s,然后在首尾分别加上s和减去s,...
2019-02-02 09:54:27 188
原创 炫酷路途
https://ac.nowcoder.com/acm/contest/331/DC++版本一题解:std因为K≤15K≤15,一些人看到这个应该直接就状压了,题目放过了这种做法。但事实上,我们可以将所有额外连边的点再加上起点终点构成一张单独的图。根据题目数据范围,上述最多一共只有32个点。随后计算这些点两两间的距离并求起点到终点最短路即可。(因为是有向图,非常好求)...
2019-02-02 09:52:49 238
原创 炫酷迷宫
https://ac.nowcoder.com/acm/contest/331/CC++版本一题解:std比如4*4,K=10的时候,很容易构造出:....xxx..xx.....于是得到了一种绕圈的想法。但是在比如5*2,K=7中,绕圈法又遇到了阻碍,不如直走换边法,即.x......x.将这两种方法合并起来,即可以得到一种看起来还不错的解法。...
2019-02-02 09:50:25 338
原创 炫酷五子棋
https://ac.nowcoder.com/acm/contest/331/B题解:std五子棋只需要计算同方向连续的五个子即可。所以对于每次落子,我们只需要知道其4个方向(双向)连续的子数(只需要查找至多4*8个位置是否存在即可)。需要利用一些简单的剪枝降低这个查找次数(比如遇到五子即退出,比如遇到不连续则continue之类)。通过以上优化,使用set< pa...
2019-02-02 09:47:58 293
原创 炫酷双截棍
https://ac.nowcoder.com/acm/contest/331/AC++版本一题解:std如果只有一根木条,显然答案就是一个圆弧。当有两根木条的时候,问题等价于在这个圆弧上任一点放置木条2。显然可以发现可以到达的位置是一个圆环或者一个圆(当且仅当l1=l2)。#include <bits/stdc++.h>using namespace ...
2019-02-02 09:44:27 207
原创 Applese 的减肥计划
https://ac.nowcoder.com/acm/contest/330/JPython版本一std题解: from math import *f1, f2, a = map(int, input().split())ans = sqrt(f1 ** 2 + f2 ** 2 + 2 * f1 * f2 * cos(a * pi / 180))print("%....
2019-02-01 12:10:37 458
原创 Applese 的回文串
https://ac.nowcoder.com/acm/contest/330/IC++版本一题解:std可以认为插入和删除是等价的操作。想到这一点,这题就会好做很多。如果这个串本身就是回文串,答案一定是Yes。否则我们只需要考虑串中对称的位置不相等的两个字符,分别尝试把它们删掉后判断一下是不是回文的就行了。#include <bits/stdc++.h>us...
2019-02-01 12:08:45 213
C++课程设计-便利店管理系统.rar
2019-05-14
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人