随笔分类 - 我的比赛
-
leetcode周赛 232
摘要:A:水题,给定两个字符串,问能否只交换一次使得两字符串相等。 解法1:记录两字符串不相等的位置。 1 class Solution { 2 public: 3 bool areAlmostEqual(string s1, string s2) { 4 int n=s1.length(); 5 int 阅读全文
-
Codeforces Round #707
摘要:A:模拟题,每次进站加上应该要的时间和延迟的时间 每次等待的时候需要题给定的两个条件都满足。 注意:最后一站不需要等待,所以需要单独考虑。 1 #include<cstring> 2 #include<algorithm> 3 #include<iostream> 4 using namespace 阅读全文
-
Codeforces Round #706 A~C
摘要:A:给了一个比较复杂的定义,但是仔细读了之后就会发现问的就是字符串s的回文长度是否大于等于k,例如abqewba的回文长度是2. 1 #include<algorithm> 2 #include<iostream> 3 using namespace std; 4 5 int main(void){ 阅读全文
-
leetcode周赛 231
摘要:A:水题。 解法1:首先确定一个全为1的串,之后如果在出现1,就返回false 1 class Solution { 2 public: 3 bool checkOnesSegment(string s) { 4 bool flag=true; 5 int n=s.size(); 6 for(int 阅读全文
-
Codeforces Round #702
摘要:A:给定一个序列,一个操作是向其中任何一个位置插入一个数,问至少需要多少次操作才能保证两两之间的max(a[i],a[i+1])/min(a[i],a[i+1])<=2。 假设在i和i+1之间插入一个数,这个操作并不会影响到其他,所以我们可以线性的考虑整个序列。 那么我们现在只需要考虑如果a和b,m 阅读全文
-
leetcode周赛 227
摘要:A:问能否将一个数组通过轮换的方式得到一个单调不减的数组。 因为范围只有100,直接将数组拷贝并排序,然后对原数组轮换n次,每次进行一下判断。 1 class Solution { 2 public: 3 bool check(vector<int>&a,vector<int>& b){ 4 int 阅读全文
-
leetcode双周赛 45
摘要:A:水题,求数组中只出现一次的元素的和。 1 class Solution { 2 public: 3 int sumOfUnique(vector<int>& nums) { 4 unordered_map<int,int> m; 5 for(auto x:nums){ 6 m[x]++; 7 } 阅读全文
-
leetcode周赛 226
摘要:A:模拟题,枚举每一个数,然后求出他应该放在哪一个盒子里面,时间复杂度为n*lgn 1 class Solution { 2 public: 3 int countBalls(int l, int r) { 4 vector<int> cnt(50,0); 5 int res=0; 6 for(in 阅读全文
-
Educational Codeforces Round 103
摘要:A:题意是给定n,k,求一个包含n个正整数的序列,满足序列和能够整除k,输出该序列最小的最大值。 如果n<=k,res等于k/n+(k%n != 0) 如果n>k,那么需要将k乘上一个数z,使得k>=n。而这个z=n/k+(n%k != 0),之后再进行上述操作。 1 #include<iostre 阅读全文
-
leetcode周赛 255
摘要:https://leetcode-cn.com/contest/weekly-contest-225/ A:枚举,或者可以找规律 解法一:枚举 1 class Solution { 2 public: 3 bool check(char * a,string& b){ 4 for(int i=0;i 阅读全文
-
Codeforces Round #693
摘要:A、长和宽一直除二到奇数就好了 1 #include<iostream> 2 #include<cstring> 3 #include<algorithm> 4 #include<cstdio> 5 #include<queue> 6 #include<vector> 7 using namespa 阅读全文