随笔分类 -  一些比赛的题目

摘要:1 class Solution { 2 public: 3 typedef long long ll; 4 int minimumFinishTime(vector<vector<int>>& tires, int changeTime, int numLaps) { 5 ll miuse[100 阅读全文
posted @ 2022-02-27 17:52 matt-11 阅读(31) 评论(0) 推荐(0) 编辑
摘要://三进制状压dp; 1 class Solution { 2 public: 3 int maximumANDSum(vector<int>& nums, int k) { 4 5 int n=nums.size(); 6 int mx=1; 7 for(int i=1;i<=k;i++)mx*= 阅读全文
posted @ 2022-02-13 19:39 matt-11 阅读(22) 评论(0) 推荐(0) 编辑
摘要://排序后枚举每个位置k,表示1-k-1全部为0,剩余都为beans[k-1]; //这样对每个位置k都有结论∑sum[i]-(n-k+1)*beans[k-1];取个min就行 1 class Solution { 2 public: 3 long long minimumRemoval(vect 阅读全文
posted @ 2022-02-13 19:38 matt-11 阅读(66) 评论(0) 推荐(0) 编辑
摘要:在一个无限大的二维平面上有一个机器人。 初始时,机器人位于点 (0,0)(0,0)。 机器人可以执行四种行动指令: U — 从 (x,y)(x,y) 移动到 (x,y+1)(x,y+1); D — 从 (x,y)(x,y) 移动到 (x,y−1)(x,y−1); L — 从 (x,y)(x,y) 移 阅读全文
posted @ 2022-02-01 22:43 matt-11 阅读(117) 评论(0) 推荐(0) 编辑
摘要:给定一个 nn 个点 mm 条边的无向图。 点的编号从 11 到 nn。 图中不含重边和自环。 请你对给定图进行判断,如果该图是一个有且仅有一个环的连通图,则输出 YES,否则输出 NO。 输入格式 第一行包含两个整数 n,mn,m。 接下来 mm 行,每行包含两个整数 a,ba,b,表示点 aa  阅读全文
posted @ 2022-02-01 21:10 matt-11 阅读(26) 评论(0) 推荐(0) 编辑
摘要:1 class Solution { 2 public: 3 typedef long long ll; 4 string subStrHash(string s, int k, int mod, int len, int hashValue) { 5 string ans=""; 6 int n= 阅读全文
posted @ 2022-02-01 16:33 matt-11 阅读(48) 评论(0) 推荐(0) 编辑
摘要:1 const int N=2e4+5; 2 int fa[N],sz[N],G[N]; 3 class Solution { 4 public: 5 6 inline int fd(int x){return fa[x]==x?x:fa[x]=fd(fa[x]);} 7 inline void m 阅读全文
posted @ 2022-02-01 15:59 matt-11 阅读(48) 评论(0) 推荐(0) 编辑
摘要:1 #include<bits/stdc++.h> 2 using namespace std; 3 4 int main() 5 { 6 string s; 7 cin>>s; 8 int ans=0,cnt=0; 9 for(auto &p:s) 10 { 11 if(p=='(')cnt++; 阅读全文
posted @ 2022-01-09 20:22 matt-11 阅读(39) 评论(0) 推荐(0) 编辑
摘要:1 #include<bits/stdc++.h> 2 using namespace std; 3 int n; 4 5 unordered_map<string,set<string>>mp; 6 vector<string>vec; 7 unordered_map<string,int>ch; 阅读全文
posted @ 2022-01-09 20:19 matt-11 阅读(18) 评论(0) 推荐(0) 编辑
摘要:1 任选两颗A,B两颗种子,pa是种A种子需要的天数,ga是A种子开花需要的天数; 2 1.考虑先种A,后种B 3 mina_day=max(pa+ga,pa+pb+gb); 4 2.先种B,后种A; 5 minb_day=max(pb+gb,pb+pa+ga); 6 7 不妨设ga>gb; 8 p 阅读全文
posted @ 2022-01-09 18:02 matt-11 阅读(57) 评论(0) 推荐(0) 编辑
摘要:1 class Solution { 2 public: 3 int minSwaps(vector<int>& nums) { 4 int n=nums.size(),sum1=0; 5 for(auto &p:nums)if(p)sum1++; 6 for(int i=0;i<n;i++)num 阅读全文
posted @ 2022-01-09 14:06 matt-11 阅读(86) 评论(0) 推荐(0) 编辑
摘要:1 class Solution { 2 public: 3 int wordCount(vector<string>& startWords, vector<string>& targetWords) { 4 int n=startWords.size(),ans=0; 5 unordered_s 阅读全文
posted @ 2022-01-09 13:54 matt-11 阅读(29) 评论(0) 推荐(0) 编辑
摘要:1 class Solution { 2 public: 3 int maximumInvitations(vector<int>& favorite) { 4 int n=favorite.size(); 5 vector<int>ind(n); 6 for(int i=0;i<n;i++)ind 阅读全文
posted @ 2022-01-03 11:34 matt-11 阅读(117) 评论(0) 推荐(0) 编辑
摘要:1 class Solution { 2 public: 3 const int N=1e5+5; 4 vector<long long> getDistances(vector<int>& arr) { 5 int n=arr.size(); 6 vector<int>v[N]; 7 vector 阅读全文
posted @ 2021-12-30 17:53 matt-11 阅读(32) 评论(0) 推荐(0) 编辑
摘要:1 class Solution { 2 public: 3 vector<int> recoverArray(vector<int>& nums) { 4 multiset<int>s; 5 int n=nums.size(); 6 sort(nums.begin(),nums.end()); 7 阅读全文
posted @ 2021-12-30 17:41 matt-11 阅读(38) 评论(0) 推荐(0) 编辑
摘要:1 #include<bits/stdc++.h> 2 using namespace std; 3 const int N=1e3+5; 4 int px[N],py[N],x[N],y[N],r[N]; 5 bitset<N>bt[N],t; 6 long long pow_x(int x) 7 阅读全文
posted @ 2021-12-30 15:36 matt-11 阅读(38) 评论(0) 推荐(0) 编辑
摘要:1 #include<bits/stdc++.h> 2 using namespace std; 3 4 int main() 5 { 6 int n,ans=0; 7 cin>>n; 8 for(int i=1;i<=(1<<9);i++)//10位数,考虑每位取0.1转成2进制表示 9 { 10 阅读全文
posted @ 2021-12-30 15:04 matt-11 阅读(20) 评论(0) 推荐(0) 编辑
摘要:1 class Solution { 2 public: 3 long long getDescentPeriods(vector<int>& prices) { 4 int n=prices.size(); 5 long long dp[n+1]; 6 for(int i=1;i<=n;i++)d 阅读全文
posted @ 2021-12-19 14:33 matt-11 阅读(19) 评论(0) 推荐(0) 编辑
摘要:1 class Solution { 2 3 public: 4 int kIncreasing(vector<int>& arr, int k) { 5 int n=arr.size(); 6 int st[n],top=0,ans=0,cnt=0; 7 for(int i=0;i<k;i++) 阅读全文
posted @ 2021-12-19 14:30 matt-11 阅读(67) 评论(0) 推荐(0) 编辑
摘要:1 #include<bits/stdc++.h> 2 using namespace std; 3 int a,b; 4 int gd; 5 vector<int>v; 6 int main() 7 { 8 9 cin>>a>>b; 10 int n; 11 cin>>n; 12 gd=gcd(a 阅读全文
posted @ 2021-12-18 22:26 matt-11 阅读(20) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示