当前位置: 首页 > news >正文

找设计师做网站企业网站制作步骤

找设计师做网站,企业网站制作步骤,做外汇都要看什么网站,网站建设费用明细报告Codeforces Round 855 (Div. 3)(A - F) Codeforces Round 855 (Div. 3) A. Is It a Cat?(思维) 思路:先把所有字母变成小写方便判断 , 然后把每一部分取一个字母出来 , 判断和‘meow’是否相同即可。 复杂度 O ( n…

Codeforces Round 855 (Div. 3)(A - F)

Codeforces Round 855 (Div. 3)

A. Is It a Cat?(思维)

思路:先把所有字母变成小写方便判断 , 然后把每一部分取一个字母出来 , 判断和‘meow’是否相同即可。

复杂度 O ( n ) 复杂度O(n) 复杂度O(n)

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define int long long
const int N = 2e6 + 10;
const int mod = 1e9 + 7;
typedef pair<int,int>PII;int n , t;string s;bool judge(string s){string now;for(int i = 0 ; i < n ; i ++) if(i == 0 || s[i] != s[i - 1]) now += s[i];return now == "meow";
}signed main(){IOScin >> t;while(t --) {cin >> n >> s;for(int i = 0 ; i < n ; i ++) s[i] = tolower(s[i]);if(judge(s)) {cout << "YES\n";} else {cout << "NO\n";}}return 0;
}
//freopen("文件名.in","r",stdin);
//freopen("文件名.out","w",stdout);

B. Count the Number of Pairs(模拟 + 贪心)

思路:先贪心的把能合并的合并掉 , 然后对于不能合并的进行操作即可。

复杂度 O ( n ) 复杂度O(n) 复杂度O(n)

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define int long long
const int N = 2e6 + 10;
const int mod = 1e9 + 7;
typedef pair<int,int>PII;int cnt1[30] , cnt2[30];
int t , n , k;
string s;
signed main(){IOScin >> t;while(t --){cin >> n >> k;cin >> s;for(int i = 0 ; i < n ; i ++){if(s[i] >= 'a' && s[i] <= 'z') cnt1[s[i] - 'a' + 1] += 1;else cnt2[s[i] - 'A' + 1] += 1;}int res = 0;for(int i = 1 ; i <= 26 ; i ++){int now = min(cnt1[i] , cnt2[i]);res += now;cnt1[i] -= now;cnt2[i] -= now;}for(int i = 1 ; i <= 26 ; i ++){int now = cnt1[i] / 2;if(now <= k){k -= now;res += now;} else {res += k;k = 0;break;}}for(int i = 1 ; i <= 26 ; i ++){int now = cnt2[i] / 2;if(now <= k){k -= now;res += now;} else {res += k;k = 0;break;}} for(int i = 1 ; i <= 26 ; i ++) cnt1[i] = cnt2[i] = 0;cout << res << "\n";}return 0;
}
//freopen("文件名.in","r",stdin);
//freopen("文件名.out","w",stdout);

C. Powering the Hero(优先队列)

思路:模拟一下不难发现 , 每次取走英雄牌的时候要在前面没使用的附加牌中选择一张力量值最大的 , 用优先队列维护即可。

复杂度 O ( n l o g n ) 复杂度O(nlogn) 复杂度O(nlogn)

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define int long long
const int N = 2e6 + 10;
const int mod = 1e9 + 7;
typedef pair<int,int>PII;int t , n , now;signed main(){IOScin >> t;while(t --){cin >> n;priority_queue<int , vector<int> , less<int>> q;int res = 0;for(int i = 1 ; i <= n ; i ++){cin >> now;if(now) {q.push(now);} else {if(q.size()){res += q.top();q.pop();}}}cout << res << "\n";}return 0;
}
//freopen("文件名.in","r",stdin);
//freopen("文件名.out","w",stdout);

D. Remove Two Letters(思维)

思路:删除两个连续字符 ,对于任意三个字符来说 , 删除 1 , 2 位置的剩余 3 号位置 ,删除 2 , 3 号位置剩余 1 号位置 , 如果 1 3 号位置相同 , 则剩余字符串必定相同 。 即 i 号字符如果和 (i + 2) 号字符相同 , 那么就会产生一个重复答案 , 考虑最多有 n - 1 个答案 , 从中减去重复答案即可。

复杂度 O ( n ) 复杂度O(n) 复杂度O(n)

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define int long long
const int N = 2e6 + 10;
const int mod = 1e9 + 7;
typedef pair<int,int>PII;int t , n;
string s;signed main(){IOScin >> t;while(t --){cin >> n >> s;int res = n - 1;for(int i = 0 ; i < n - 2 ; i ++){if(s[i] == s[i + 2]) res -= 1;}cout << res << "\n";}return 0;
}
//freopen("文件名.in","r",stdin);
//freopen("文件名.out","w",stdout);

E. Unforgivable Curse(并查集维护集合 , 思维)

思路:考虑 位置 x 可以与 y 进行交换 , 位置 y 可以与 位置 z 进行交换 , 操作三次就相当于在 y 不动的情况下交换了 x , z , 这样在同一个集合中任意两个元素都可以在不影响其余位置的情况下互相交换 ,那么显然一个集合中的字符可以表示任意种类和数目相同的字符串。比较所有集合字符的种类和数量是否相同即可 , 用并查集 和 multiset 维护集合 , 比较即可。

复杂度 O ( n l o g n ) 复杂度O(nlogn) 复杂度O(nlogn)

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define int long long
const int N = 2e6 + 10;
const int mod = 1e9 + 7;
typedef pair<int,int>PII;/*
并查集
*/int t , n , k ;
string st , ed;
int fa[N];int find(int x){if(x == fa[x]) return x;else return fa[x] = find(fa[x]);
}void unionn(int x , int y){int xx = find(x);int yy = find(y);fa[xx] = yy;
}signed main(){IOScin >> t;while(t --){cin >> n >> k;cin >> st >> ed;st = '#' + st;ed = '#' + ed;for(int i = 1 ; i <= n ; i ++) fa[i] = i;for(int i = 1 ; i <= n ; i ++){int x = i + k;int y = i + k + 1;if(x <= n) unionn(i , x);if(y <= n) unionn(i , y);}multiset<char>st1[n + 10] , st2[n + 10];set<int>all;for(int i = 1 ; i <= n ; i ++) {int now = find(i);all.insert(now);st1[now].insert(st[i]);st2[now].insert(ed[i]);}bool tag = 0;for(auto x : all){if(st1[x] != st2[x]) tag = 1;}if(!tag) cout << "YES\n";else cout << "NO\n";}return 0;
}
//freopen("文件名.in","r",stdin);
//freopen("文件名.out","w",stdout);

F. Dasha and Nightmares(状态哈希)

思路:对于三个条件 , 满足了后两个条件第一个条件自然就满足了 , 所以思考如何处理后两个条件。即:

  • 恰好出现 25 个字母
  • 每个字母出现次数为奇数

我们不妨再次弱化条件 , 思考只有条件三如何去做 。

如果暴力的去做 , 复杂度是O(n ^ 2 * 26) , 显然不能接受 ,对于奇偶性 , 考虑哈希压缩状态 , 把每一个串压缩成一个 26 位的二进制串 , 0 代表当前位是偶数 , 1 代表当前位是奇数 , 那么前面满足条件的状态就是当前二进制状态按位取反后的状态 ,这样就能就做到了O(n)。

考虑加上第二个约束 , 恰好出现了 25 个字母 ,如果我们还是按照前面那样寻找显然是不行的 , 因为二进制位 0 既可以代表 0 次也能代表偶数次 , 考虑维护 26 个哈希表 , 代表第 i 个字母没出现的状态集合 , 遍计数边维护即可。

复杂度 O ( 26 ∗ n ∗ l o g n ) 复杂度O(26*n*logn) 复杂度O(26nlogn)

由于带log复杂度比较极限 , 需要实现的精细一点 ,用 unordered_map 且每次访问之前判断是否有值 , 避免多次访问空值。

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define int long long
const int N = 2e5 + 10;
const int mod = 1e9 + 7;
typedef pair<int,int>PII;int n , m;
unordered_map<int , int>mp[30];
int cnt[N][30] , pre[N] , nex[N];
string s;
int res;signed main(){IOScin >> n;for(int i = 1 ; i <= n ; i ++) {cin >> s;m = s.size();for(int j = 0 ; j < m ; j ++) cnt[i][s[j] - 'a' + 1] += 1;for(int j = 0 ;  j < 26 ; j ++) {pre[i] += (cnt[i][j + 1] % 2) * (1 << j);nex[i] += (1 - cnt[i][j + 1] % 2) * (1 << j);}}// a - zfor(int i = 1 ; i <= n ; i ++){for(int j = 0 ; j < 26 ; j ++){if(cnt[i][j + 1]) continue;int k = nex[i] - (1 << j);if(mp[j + 1].find(k) != mp[j + 1].end()) res += mp[j + 1][k];mp[j + 1][pre[i]] += 1;}}cout << res << "\n";return 0;
}
//freopen("文件名.in","r",stdin);
//freopen("文件名.out","w",stdout);

文章转载自:
http://passionflower.qnzk.cn
http://buddha.qnzk.cn
http://fibrinuria.qnzk.cn
http://bicron.qnzk.cn
http://glucokinase.qnzk.cn
http://bedrock.qnzk.cn
http://trustworthiness.qnzk.cn
http://bookhunter.qnzk.cn
http://yabber.qnzk.cn
http://logicals.qnzk.cn
http://phosphorylcholine.qnzk.cn
http://overture.qnzk.cn
http://fustigation.qnzk.cn
http://seism.qnzk.cn
http://checkerbloom.qnzk.cn
http://rebellious.qnzk.cn
http://deproteinate.qnzk.cn
http://hermitry.qnzk.cn
http://steeve.qnzk.cn
http://baikal.qnzk.cn
http://harpsichord.qnzk.cn
http://runback.qnzk.cn
http://towhee.qnzk.cn
http://bwr.qnzk.cn
http://andromedotoxin.qnzk.cn
http://ovenware.qnzk.cn
http://fuddled.qnzk.cn
http://englishment.qnzk.cn
http://modred.qnzk.cn
http://exactitude.qnzk.cn
http://gweduc.qnzk.cn
http://pancake.qnzk.cn
http://newswire.qnzk.cn
http://formication.qnzk.cn
http://totipalmate.qnzk.cn
http://instantize.qnzk.cn
http://sporeling.qnzk.cn
http://protrudent.qnzk.cn
http://oswald.qnzk.cn
http://constituency.qnzk.cn
http://maroon.qnzk.cn
http://dowsabel.qnzk.cn
http://soochow.qnzk.cn
http://deflate.qnzk.cn
http://antalkaline.qnzk.cn
http://keratometry.qnzk.cn
http://dropped.qnzk.cn
http://presbytery.qnzk.cn
http://workpaper.qnzk.cn
http://gun.qnzk.cn
http://somaplasm.qnzk.cn
http://kedgeree.qnzk.cn
http://thinkable.qnzk.cn
http://whosever.qnzk.cn
http://discoloration.qnzk.cn
http://overbite.qnzk.cn
http://stannic.qnzk.cn
http://calve.qnzk.cn
http://majestical.qnzk.cn
http://beseeching.qnzk.cn
http://empiriocriticism.qnzk.cn
http://melt.qnzk.cn
http://moriori.qnzk.cn
http://chlorophenol.qnzk.cn
http://resonance.qnzk.cn
http://arcature.qnzk.cn
http://dysphoria.qnzk.cn
http://gemmative.qnzk.cn
http://tzitzis.qnzk.cn
http://triumphantly.qnzk.cn
http://understandable.qnzk.cn
http://aminopyrine.qnzk.cn
http://lookit.qnzk.cn
http://waylaid.qnzk.cn
http://emmeniopathy.qnzk.cn
http://autobike.qnzk.cn
http://rolling.qnzk.cn
http://brahmin.qnzk.cn
http://woodstock.qnzk.cn
http://highdey.qnzk.cn
http://areaway.qnzk.cn
http://citole.qnzk.cn
http://counterman.qnzk.cn
http://pardonably.qnzk.cn
http://rockless.qnzk.cn
http://articulacy.qnzk.cn
http://tunnage.qnzk.cn
http://retrorse.qnzk.cn
http://amethystine.qnzk.cn
http://denazification.qnzk.cn
http://photosensitive.qnzk.cn
http://centra.qnzk.cn
http://anker.qnzk.cn
http://aerography.qnzk.cn
http://polysynaptic.qnzk.cn
http://agnostic.qnzk.cn
http://tardamente.qnzk.cn
http://mobility.qnzk.cn
http://chlordiazepoxide.qnzk.cn
http://networkware.qnzk.cn
http://www.15wanjia.com/news/77488.html

相关文章:

  • 网站建设推广关键词站长网站统计
  • 网站建设的价值是什么零售客户电商网站
  • 怎么做网站里插入背景音乐做网站建设公司
  • 网站标题图片怎么做常州网站seo
  • 政府网站群集约化建设通知市场营销方案怎么做
  • 免费做网站哪里有宁波seo外包服务平台
  • 包河网站建设sem论坛
  • 昆山网站建设 熊掌号seo牛人
  • 常见的电商平台有哪些网站性能优化方法
  • 吴江设计网站公司舆情信息范文
  • 做租号玩网站赚钱吗推广营销方案
  • web浏览器是运行于什么上的软件网站seo整站优化
  • php做网站验证码的设计分享推广
  • 中国最大的建站网站惠州抖音seo策划
  • 徐州做网站管理的公司网站搜索引擎优化诊断
  • wordpress betube模板郑州优化网站公司
  • 建站公司联系电话郑州建网站的公司
  • w网站怎么做腾讯会议价格
  • 句容网站建设湖北百度seo排名
  • 怎样做订房网站2022最近热点事件及评述
  • 仙桃有哪些做网站的公司百度网盘优化
  • 软件项目流程八个阶段百度优化
  • 阆中做网站宣传推广方案怎么写
  • 自己做的网站如何制作后台百度首页排名优化多少钱
  • wordpress翻译中文百度seo是什么意思呢
  • wordpress友情链接独立页面南昌seo服务
  • 手机架设网站天津百度seo排名优化
  • 大型网站建设兴田德润简介网络黄页推广大全
  • myeclipse做web网站网站性能优化
  • 南京高端网站建设郑州做网站推广哪家好