- 博客(124)
- 收藏
- 关注
原创 2022“杭电杯”中国大学生算法设计超级联赛(7) 2022杭电多校第七场
我们先考虑开始的三角形,如果三个点都选上或者任选两个点,那就违背了我们说的两两不存在边,但如果都不选,那么剩下的图一定有环,所以我们必须在三个点中选择一个点,我们枚举这个情况并确定二分图,最后遍历得到答案即可。有n个点,每个点有对应的权重,1,2,3号点两两相连,从第四号点开始,给出两个点,这两点这之间存在边,将该点和这两个点进行连接,你需要选择一些点,这些点两两之间不存在边,且剩下的点构成一个无环的无向图。......
2022-08-10 20:55:53
486
原创 2022“杭电杯”中国大学生算法设计超级联赛(5)杭电多校第五场
用vector以到达时间为第一关键字,所需时间为第二关键词排序,优先队列中存储每个人的离开时间每次插入前先把离开时间小于到达时间的人从队列中清除,并更新到线段树上。有n个人买东西,已知到达时间和花费时间,每个人会优先选择排队人数最少的,其次是编号较小的。用线段树维护当前人数最小的队列和位置。问最后一个人离开的时间是多少。tags线段树,优先队列。.........
2022-08-03 09:58:44
727
原创 2022“杭电杯”中国大学生算法设计超级联赛(3)杭电多校第三场
为262144,猜想为nlogn的做法,考虑是否能二分,注意因为本题时间比较紧张,所以R应该为所有技能释放的最长时间,而不是INF,否则很容易超时。然后我们考虑如何二分,因为技能对BOSS的伤害是一段区间,所以我们用记忆化搜索得到本次时间内按某一顺序击败BOSS的最短时间。小Q在玩RPG游戏,他尝试尽快击败BOSS,BOSS有H单位的血量,小Q有N个技能,每个技能花费。然后因为伤害是连续的,我们可以考虑用前缀和得到该技能施展某一秒时的总伤害,可以优化时间。,问最快击败BOSS在哪一帧,起始在第0帧。....
2022-07-27 16:06:31
811
2
原创 “蔚来杯“2022牛客暑期多校训练营2
这里我们采取的方式是组内升序,组间降序,那么我们把它分成sqrt(n)个组,每个组内有sqrt(n)个数,那么答案就是。最长上升子序列长度和最长下降子序列长度的最大值,问你这个的最小值是多少。给你一个数字n,你需要构造一个1-n的排列,排列的价值为。.....................
2022-07-26 10:33:59
690
原创 “蔚来杯“2022牛客暑期多校训练营1
本题是期望DP,很容易想到最优策略就是如果新摸到的牌能和手中的单牌凑出对子就留着,并随便打出一张手里单牌,否则就把摸到的牌打出。给你13张牌,每次摸一张打一张,求最优策略出牌有七个对子时的期望。那么当前牌堆中还有136-i-13张牌,设为a。表示已经摸了i张牌,手里还有j张单牌的情况。tags期望DP记忆化搜索。,那么摸到非手中单排的期望为。摸到手中单牌的期望是。.........
2022-07-22 11:31:02
437
原创 2022“杭电杯”中国大学生算法设计超级联赛 (2) 杭电多校第二场
预处理一下7X31X365之内需要多少步才能完成(或者不能完成),大于这个数的我们可以直接把它取模至这个范围以内。那么我们只要算出那么最后剩下的质因子大不大于P,Q即可然后处理一下得到答案。否则两个大于P,Q的质因子相乘不可能等于PxQ-1。所以满足此类要求的质因子只有一个。签到题,稍微处理一下输出即可。因为题目要求M>=P,Q。........................
2022-07-22 01:11:50
1649
2
原创 2022“杭电杯”中国大学生算法设计超级联赛 (1) 杭电多校第一场 2 3 4 5 8 12
读取每一位,若为0则表示不通过该墙,若为1则表示可以通过该墙,并且把不能通过的墙进行标记,然后在后续的dfs中查找是否存在上述条件中可以到达终点的情况,若存在就把当前情况中的1(二进制看)记录一个最小值,最后输出即可,需要注意的是偏移的位置处理。因为数据很小,所以可以用暴力搜索的方法解决,不妨用二进制的方式遍历每一种可能,从0开始到。因为时求最大的异或和,所以我们可以用是否存在作为DP的结果。其中i表示前i个物品,j表示异或和,k表示当前的体积。给你体积和价值,问你当背包装满时最大异或和时多少。......
2022-07-20 11:50:38
1730
原创 Acwing -树型DP(自用)
给定一棵树,树中包含 n 个结点(编号1~n)和 n−1 条无向边,每条边都有一个权值。现在请你找到树中的一条最长路径。换句话说,要找到一条路径,使得使得路径两端的点的距离最远。注意:路径中可以只包含一个点。这是树型DP的第一类题型并没有类似于DP中的表达式,而是借用DP的思想进行解题使用dfs,从任意一点开始都可,函数中标记父节点保证遍历方向正确,同时记录d1和d2其中d1为当前节点的最长距离,d2为当前节点的次长距离,那么最长路径就是d1+d2,用ans记录一个最大值同时dist变量返回当
2022-07-06 01:14:34
552
原创 H - Lawn of the Dead HDU - 6992
https://acm.hdu.edu.cn/showproblem.php?pid=6992给你一张nxm的图,从(1,1)开始可以向下或者向右移动,问可以遍历到的格子数目遍历每行处理可以遍历到的格子以区间为单位进行处理其中v1代表上一行中可以遍历的区间v2代表本行中的可被遍历区间(但不一定能被遍历)经过迭代器进行比较可以确定答案...
2022-07-06 00:01:40
182
原创 Codeforces Round #792 (Div. 1 + Div. 2)
A. Digit MinimizationThere is an integer n without zeros in its decimal representation. Alice and Bob are playing a game with this integer. Alice starts first. They play the game in turns.On her turn, Alice must swap any two digits of the integer that ar
2022-05-21 00:11:23
401
原创 Codeforces Round #785 (Div. 2) A-D
A. Subtle Substring Subtraction给你一个字符串,Alice先手并取偶数长度的子串,Bob后手并取奇数长度的子串,问取完整个字符串谁的值最大,差值是多少易知Alice一定会取最长的偶数子串,先特判一下字符串长度为1时Bob赢然后如果是偶数长度就直接取完,否则判断一下第一个字符和最后一个字符谁大,留一个小的给Bob剩下的全部取完就行/**************** *@description:for the Escape Project *@author: Nebul
2022-05-01 11:23:51
322
原创 Educational Codeforces Round 125 (Rated for Div. 2) D. For Gamers. By Gamers.
D. For Gamers. By Gamers.time limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMonocarp is playing a strategy game. In the game, he recruits a squad to fight monsters. Before each battle, Monocarp has C
2022-03-23 01:24:57
503
原创 C - Phone List POJ - 3630(tire 字典树)
C - Phone List POJ - 3630Given a list of phone numbers, determine if it is consistent in the sense that no number is the prefix of another. Let’s say the phone catalogue listed these numbers:Emergency 911Alice 97 625 999Bob 91 12 54 26In this case, it
2021-11-09 00:38:19
177
原创 B - Babelfish POJ - 2503(tire 字典树)
B - Babelfish POJ - 2503You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them.InputInput consists of up to 100,000 diction
2021-11-09 00:34:21
199
原创 A - 统计难题 HDU - 1251(trie 字典树)
A - 统计难题 HDU - 1251Ignatius最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单词数量(单词本身也是自己的前缀).Input输入数据的第一部分是一张单词表,每行一个单词,单词的长度不超过10,它们代表的是老师交给Ignatius统计的单词,一个空行代表单词表的结束.第二部分是一连串的提问,每行一个提问,每个提问都是一个字符串.注意:本题只有一组测试数据,处理到文件结束.Output对于每个提问,给出以该
2021-11-09 00:20:03
211
原创 PAT甲级1044
solution#include <iostream>#include <vector>using namespace std;const int N = 100010;int n, k;int s[N];vector<int> anss;void solve(int i, int &j, int &tempsum){ int left = i, right = n; while (left < right)
2021-09-08 17:04:59
110
原创 PAT甲级1043
solution#include <iostream>#include <vector>using namespace std;bool isMirror;vector<int> pre, post;void getpost(int root, int tail){ if (root > tail) return; int i = root + 1, j = tail; if (!isMirror) {
2021-09-08 15:46:16
110
原创 PAT甲级1042
solution#include <iostream>#include <algorithm>using namespace std;const int N = 55, M = 1000010;int a[N], b[M], c[N];void solve(int x, int y){ swap(a[x], a[y]);}int main(){ for (int i = 1; i < N; i++) a[i] = i;
2021-09-08 13:55:54
128
原创 PAT甲级1041
solution#include <iostream>using namespace std;const int N = 100010;int a[N], m[N];int main(){ int n; scanf("%d", &n); for (int i = 0; i < n; i++) { cin >> a[i]; m[a[i]]++; } for (int i = 0;
2021-09-08 12:46:17
122
原创 PAT甲级1040
solution#include <iostream>#include <cstring>using namespace std;string a;int check(int i){ int count1 = 1; int x = i - 1, y = i + 1; while (a[x] == a[y] && x >= 0 && y < a.size()) { x--;
2021-09-08 12:25:18
115
原创 PAT甲级1039
solution#include <iostream>#include <queue>#include <cstring>#include <set>#include <map>using namespace std;const int N = 50010;map<string, set<int>> x1;int idxnumber = 1;int main(){ int n, k; s
2021-09-08 12:12:00
88
原创 PAT甲级1038
solution#include <iostream>#include <cstring>#include <algorithm>using namespace std;const int N = 10010;string a[N];bool cmp(string a, string b){ return a + b < b + a;}string ans;int main(){ int n; cin >>
2021-09-08 11:03:29
80
原创 PAT甲级1037
solution#include <cstdio>#include <vector>#include <algorithm>using namespace std;int main() { int m, n, ans = 0, p = 0, q = 0; scanf("%d", &m); vector<int> v1(m); for(int i = 0; i < m; i++) scanf
2021-09-07 15:23:41
82
原创 PAT甲级1036
solution#include<bits/stdc++.h>using namespace std;string nm;char ge;string id;int grade;int n;int main(){ int n; cin>>n; string fn="",mn=""; string fid,mid; int fg=-1,mg=101; for(int i=1;i<=n;i++) {
2021-09-07 14:22:48
68
原创 PAT甲级1035
solution#include <iostream>using namespace std;const int N = 1010;string a[N], b[N];int main(){ int n; scanf("%d\n", &n); string temp1, temp2; int count = 0; int idx = 1; for (int i = 1; i <= n; i++) {
2021-09-07 14:05:34
149
原创 PAT甲级1034
solution#include <iostream>#include <map>using namespace std;int G[2010][2010], wight[2010];bool vis[2010];map<string, int> stringToInt;map<int, string> intToString;map<string, int> ans;int idNumber = 1, k;int stoifu
2021-09-07 13:52:46
86
原创 PAT甲级1033
solution#include <iostream>#include <algorithm>#include <vector>using namespace std;const int inf = 99999999;struct station{ double price, dis;};bool cmp1(station a, station b){ return a.dis < b.dis;}int main(){
2021-09-07 12:03:40
72
原创 PAT甲级1033
solution#include <iostream>#include <algorithm>#include <vector>using namespace std;const int inf = 99999999;struct station{ double price, dis;};bool cmp1(station a, station b){ return a.dis < b.dis;}int main(){
2021-09-06 20:15:51
73
原创 PAT甲级1032
solution#include <iostream>#include <cstring>using namespace std;struct node{ char data; int key, flag;} add[100010];int main(){ int st1, st2, n; cin >> st1 >> st2 >> n; for (int i = 1; i <= n; i
2021-09-06 17:14:11
75
原创 PAT甲级1031
solution#include <iostream>#include <cstring>using namespace std;int main(){ string a; cin >> a; if (a.size() % 2 == 0) { int count = (a.size() + 2) / 3, idx = a.size() - 2 * count + 2; for (int i = 0;
2021-09-06 16:23:02
93
原创 PAT甲级1030
solution#include <iostream>#include <vector>#include <cstring>#include <algorithm>using namespace std;const int N = 510;vector<int> pre[N];int vis[N];int map[510][510], dis[510], money[510][510];int n, m, s, d;const
2021-09-06 16:00:30
141
原创 PAT甲级1029
solution#include <iostream>#include <vector>#include <algorithm>using namespace std;vector<long long> ans;int main(){ long long n; cin >> n; for (long long i = 0; i < n; i++) { long long x;
2021-09-06 15:59:57
62
原创 PAT甲级1028
solution#include <iostream>#include <cstring>#include <algorithm>using namespace std;const int N = 100010;struct node{ int a, c; string b;} records[N];bool cmp1(node x, node y){ return x.a < y.a;}bool cmp2(node
2021-09-06 15:59:50
61
原创 PAT甲级1027
solution#include <iostream>#include <algorithm>#include <cstring>using namespace std;int tt[100000];char s[14] = "0123456789ABC";string work2(int y){ string result = ""; if (y == 0) { return "00"; } whi
2021-09-05 22:14:32
83
原创 PAT甲级1025
solution#include <iostream>#include <cstring>#include <algorithm>#include <vector>using namespace std;const int N = 310;struct node{ long long x; int loc, fin, id, score;};vector<node> tester;bool cmp1(node
2021-09-05 18:29:08
67
原创 PAT甲级1024
solution#include <iostream>#include <algorithm>#include <cstring>using namespace std;string s;void add(string t){ int carry = 0; for (int i = 0; i < t.size(); i++) { s[i] = s[i] + t[i] + carry - '0';
2021-09-05 17:43:35
61
原创 PAT甲级1023
solution#include <cstdio>#include <string.h>using namespace std;int book[10];int main() { char num[22]; scanf("%s", num); int flag = 0, len = strlen(num); for(int i = len - 1; i >= 0; i--) { int temp = num[i] - '
2021-09-05 17:08:52
69
原创 PAT甲级1022
solution#include <iostream>#include <cstring>#include <map>#include <set>using namespace std;map<string, set<int>> title, author, key, pub, year;void query(map<string, set<int>> &m, string &str
2021-09-05 16:52:13
86
原创 PAT甲级1021
solution#include <iostream>#include <vector>#include <set>#include <cstring>#include <algorithm>using namespace std;const int N = 10010;set<int> s;vector<int> map[N], v, temp;int vis[N];int maxhight = 0
2021-09-05 13:15:17
60
原创 PAT甲级1020
solution#include <iostream>#include <vector>#include <algorithm>using namespace std;const int N = 31;int in[N], post[N];struct node{ int idx, value;};bool cmp(node x, node y){ return x.idx < y.idx;}vector<node
2021-09-05 11:59:34
80
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人