随笔分类 -  题解代码

摘要:题目连接:[https://www.luogu.com.cn/problem/P2946](P2946 [USACO09MAR] Cow Frisbee Team S) AC代码: #include <bits/stdc++.h> using namespace std; # define i64 阅读全文
posted @ 2025-07-09 15:02 Frodnx 阅读(10) 评论(0) 推荐(0)
摘要:题目连接:[https://www.luogu.com.cn/problem/P1802](P1802 5 倍经验日) 注意此题会卡longlong AC代码: #include <bits/stdc++.h> using namespace std; # define int long long 阅读全文
posted @ 2025-07-09 11:16 Frodnx 阅读(8) 评论(0) 推荐(0)
摘要:#include <iostream> using namespace std; bool Mul_ = false; #define i64 long long const int N = 1e3 + 10; i64 cnt = 0; i64 numstk[N]; char opstk[N]; i 阅读全文
posted @ 2025-03-02 16:50 Frodnx 阅读(24) 评论(0) 推荐(0)
摘要:The 2024 CCPC Online Contest 补题连接:https://codeforces.com/gym/105336 D. 编码器-解码器 考虑dp,\(dp(i,j,k)\)表示 \(T\) 的子串 \(T[j,k]\)(下标 \(j\) 到下标 \(k\) )在 \(S_{i} 阅读全文
posted @ 2024-09-13 19:37 Frodnx 阅读(226) 评论(0) 推荐(0)
摘要:The 2024 Shanghai Collegiate Programming Contest 补题连接:https://codeforces.com/gym/105229 M. 不共戴天 观察样例2,注意到6个荷叶两两分成一组,共分为3组 (1,2)(3,4)(5,6) 其中对于青蛙的策略是组内 阅读全文
posted @ 2024-09-12 18:34 Frodnx 阅读(310) 评论(0) 推荐(0)
摘要:The 8th Hebei Collegiate Programming Contest 补题连接:https://codeforces.com/gym/105184 A. Update #include <bits/stdc++.h> using namespace std; int main() 阅读全文
posted @ 2024-09-08 00:07 Frodnx 阅读(331) 评论(0) 推荐(0)
摘要:思路题,set有序,lower_bound(a)可以二分寻找set中最接近的大于等于它的数 #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; set<int> s; for(int i = 1; i 阅读全文
posted @ 2024-09-06 19:54 Frodnx 阅读(29) 评论(0) 推荐(0)
摘要:使用 set_intersection() 判断两个集合之间重复元素,时间复杂度最坏O(nlogn),最好O(n) #include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; vector<s 阅读全文
posted @ 2024-09-06 17:48 Frodnx 阅读(198) 评论(0) 推荐(0)
摘要:占位符不要用%#*^之类的,测试点5和7会被卡 #include <bits/stdc++.h> using namespace std; void print(string s) { for(auto si : s) if(si == '{') cout << "<censored>"; else 阅读全文
posted @ 2024-09-04 19:20 Frodnx 阅读(197) 评论(0) 推荐(0)
摘要:#include <bits/stdc++.h> using namespace std; string func(string s, int x, int y, string s1, string s2) { x--,y--; string mid(s,x,y-x+1); s.erase(x,y- 阅读全文
posted @ 2024-09-03 15:30 Frodnx 阅读(45) 评论(0) 推荐(0)
摘要:测试点5是混过去的,已知测试点5只涉及大小写转换,n=3,第一个句子长度为奇数 #include <bits/stdc++.h> using namespace std; bool is_biaodian(char c) { if(c >= 'a' && c <= 'z' || c >= 'A' & 阅读全文
posted @ 2024-09-03 14:06 Frodnx 阅读(55) 评论(0) 推荐(0)
摘要:代码1:剪枝,非打表 #include <bits/stdc++.h> using namespace std; int l, n; const int N = 5; int arr[N * N]; int H[N], L[N]; int dfs(int x) { if(x >= n * n) { 阅读全文
posted @ 2024-09-03 11:08 Frodnx 阅读(142) 评论(0) 推荐(1)
摘要:#include <bits/stdc++.h> using namespace std; string s; bool is_hui(int x, int y) { while(x < y) { if(s[x] != s[y]) return false; ++ x, -- y; } return 阅读全文
posted @ 2024-09-02 15:18 Frodnx 阅读(25) 评论(0) 推荐(0)
摘要:模拟过程走一遍即可 #include <bits/stdc++.h> using namespace std; const int N = 110; int M[N]; #define x first #define y second int main() { int n; cin >> n; in 阅读全文
posted @ 2024-08-31 20:26 Frodnx 阅读(27) 评论(0) 推荐(0)
摘要:硬写的 // 我也不知道多长时间了,估计有40min #include <bits/stdc++.h> using namespace std; const int N = 50; int hou[N], zhong[N]; class Node { public: int val; int wei 阅读全文
posted @ 2024-08-31 19:15 Frodnx 阅读(23) 评论(0) 推荐(0)
摘要:#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; // 分别为祖宗节点,人数,房子数,总面积 int p[N], cnt[N], fangzi[N], totalarea[N], minnum[N]; // 编 阅读全文
posted @ 2024-08-30 22:16 Frodnx 阅读(24) 评论(0) 推荐(0)
摘要:基础款并查集练习题 // 13'11" #include <bits/stdc++.h> using namespace std; const int N = 1e4 + 10; int p[N], f[N]; void init() { for(int i = 1; i <= N; ++ i) p 阅读全文
posted @ 2024-08-29 22:22 Frodnx 阅读(22) 评论(0) 推荐(0)
摘要:时间复杂度 N*M≈2.5e6 #include <bits/stdc++.h> using namespace std; int n = 510, m; const int N = 510; vector<pair<int,int>> path; // 储存所有边 int p[N]; // 储存祖 阅读全文
posted @ 2024-08-29 22:02 Frodnx 阅读(27) 评论(0) 推荐(0)
摘要:#include <bits/stdc++.h> using namespace std; const int N = 1000; int p[N]; int find(int x) { if(p[x] != x) p[x] = find(p[x]); return p[x]; } int main 阅读全文
posted @ 2024-08-29 19:45 Frodnx 阅读(24) 评论(0) 推荐(0)