https://codeforces.com/contest/1234/problem/A

A. Equalize Prices Again

 #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
int n,a;
int t;
cin>>t;
ll sum = ,ans;
while(t--){
cin>>n;sum = ;
for(int i = ;i < n;++i){
cin>>a;sum+=a;
}
ans = sum/n;
if(sum%n)ans+=;
cout<<ans<<endl;
}
}

AC代码

https://codeforces.com/contest/1234/problem/B1

B1. Social Network (easy version)

https://codeforces.com/contest/1234/problem/B2

B2. Social Network (hard version)

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a;
int n ,k ,now=,fi=;
vector<ll>s;
map<ll,int>mp;
int main(){
cin>>n>>k;
for(int i = ;i < n;++i){
cin>>a;
if(mp[a]==){
mp[a]=;s.push_back(a);
if(now<k){
now++;
}
else if(now==k){
mp[s[fi]]=;fi++;
}
}
}
cout<<now<<endl;
int l =s.size()-;
int cnt=;
while(cnt<now&&l>=){
if(mp[s[l]])cnt++,cout<<s[l]<<" ";
l--;
}
cout<<endl; return ;
}

AC代码

https://codeforces.com/contest/1234/problem/C

C. Pipes

旋转一遍发现前两种其实是不同方向摆放的一种管道,后四个同理,也就是只有两个管道,一个是直流另一个会变向,然后问题就很简单了。

 #include<bits/stdc++.h>
using namespace std;
typedef long long ll; int main(){
int t,n;
cin>>t;
while(t--){
cin>>n;
string a[];cin>>a[]>>a[];
int now=,flag =;
for(int i = ;i <n;++i){
if(a[now][i]==''||a[now][i]=='')continue;
else{
now=-now;
if(a[now][i]==''||a[now][i]==''){
flag=;break;
}
}
}
if(flag==||now==)cout<<"no"<<endl;
else cout<<"yes"<<endl;
}
return ;
}

AC代码

https://codeforces.com/contest/1234/problem/D

D. Distinct Characters Queries

用线段树维护不同字母的个数orz学到了新东西,待会再看看set的做法?

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+;
int a[N],ans[];
int tree[*N][];
void build(int l,int r,int rt){
if(l==r){tree[rt][a[l]]++;return ;}
int mid=(l+r)/;
build(l,mid,rt*);
build(mid+,r,rt*+);
for(int i = ;i < ;++i)tree[rt][i]=tree[rt*][i]+tree[rt*+][i];
}
void f5(int l,int r,int rt,int x,int p,int f){
if(l==r){tree[rt][p]--;tree[rt][f]++;return ;}
int mid=(l+r)>>;
if(x<=mid)f5(l,mid,rt<<,x,p,f);
else f5(mid+,r,rt<<|,x,p,f);
for(int i = ;i < ;++i)tree[rt][i]=tree[rt<<][i]+tree[rt<<|][i];
}
void query(int l,int r,int rt,int ll,int rr){
if(r<=rr&&l>=ll){
for(int i = ;i < ;++i)ans[i]+=tree[rt][i]; return ;
}
int mid=(l+r)>>;
if(ll<=mid)query(l,mid,rt<<,ll,rr);
if(rr>mid)query(mid+,r,rt<<|,ll,rr);
}
int main()
{
ios::sync_with_stdio();
string s;cin>>s;int n = s.size();
for(int i = ;i < n;++i)a[i+]=s[i]-'a';
build(,n,);
int m;cin>>m;
while(m--){
int flag,x,l,r;char c;cin>>flag;
if(flag==){
cin>>x>>c;
f5(,n,,x,s[x-]-'a',c-'a');
s[x-]=c;
}
else{
cin>>l>>r;memset(ans,,sizeof(ans));
query(,n,,l,r);
int tot=;
for(int i = ;i < ;++i)if(ans[i])tot++;
cout<<tot<<endl;
}
}
return ;
}

AC代码

Codeforces Round #590 (Div. 3)(e、f待补的更多相关文章

  1. Codeforces Round #590 (Div. 3) Editorial

    Codeforces Round #590 (Div. 3) Editorial 题目链接 官方题解 不要因为走得太远,就忘记为什么出发! Problem A 题目大意:商店有n件商品,每件商品有不同 ...

  2. Codeforces Round #573 (Div. 1) 差F

    Codeforces Round #573 (Div. 1) E 题意:二维平面上有 n 个点,你可以放至多 m 条直线使得 (0,0) 与每个点的连线至少与一条直线相交.求原点与所有直线的距离最小值 ...

  3. Codeforces Round #575 (Div. 3) 昨天的div3 补题

    Codeforces Round #575 (Div. 3) 这个div3打的太差了,心态都崩了. B. Odd Sum Segments B 题我就想了很久,这个题目我是找的奇数的个数,因为奇数想分 ...

  4. Codeforces Round #590 (Div. 3) F

    传送门 题意: 给出一个只含前\(20\)个字符的字符串,现在可以选择一段区间进行翻转,问区间中字符各不相同时,最长长度为多少. 思路: 首先,容易将题意转换为选择两个字符各不相同的区间,然后长度相加 ...

  5. Codeforces Round #541 (Div. 2) (A~F)

    目录 Codeforces 1131 A.Sea Battle B.Draw! C.Birthday D.Gourmet choice(拓扑排序) E.String Multiplication(思路 ...

  6. Codeforces Round #532 (Div. 2):F. Ivan and Burgers(贪心+异或基)

    F. Ivan and Burgers 题目链接:https://codeforces.com/contest/1100/problem/F 题意: 给出n个数,然后有多个询问,每次回答询问所给出的区 ...

  7. Codeforces Round #590 (Div. 3) E. Special Permutations

    链接: https://codeforces.com/contest/1234/problem/E 题意: Let's define pi(n) as the following permutatio ...

  8. Codeforces Round #590 (Div. 3) D. Distinct Characters Queries(线段树, 位运算)

    链接: https://codeforces.com/contest/1234/problem/D 题意: You are given a string s consisting of lowerca ...

  9. Codeforces Round #600 (Div. 2)E F

    题:https://codeforces.com/contest/1253/problem/E 题意:给定n个信号源,俩个参数x和s,x代表这个信号源的位置,s代表这个信号源的波及长度,即这个信号源可 ...

随机推荐

  1. layer 相关网址

    layer 1.8.5 官方网址: http://layer.layui.com/1.8.5/ API网址: http://layer.layui.com/1.8.5/api.html

  2. 彩色图像--色彩空间 CIELAB、CIELUV

    学习DIP第65天 转载请标明本文出处:http://blog.csdn.net/tonyshengtan ,出于尊重文章作者的劳动,转载请标明出处!文章代码已托管,欢迎共同开发:https://gi ...

  3. python学习之路(10)--难点

    递归函数 在函数内部,可以调用其他函数.如果一个函数在内部调用自身本身,这个函数就是递归函数. 举个例子,我们来计算阶乘n! = 1 x 2 x 3 x ... x n,用函数fact(n)表示,可以 ...

  4. Spring boot之MyBatis

    文章目录1. 环境依赖2. 数据源2.1. 方案一 使用 Spring Boot 默认配置2.2. 方案二 手动创建3. 脚本初始化4. MyBatis整合4.1. 方案一 通过注解的方式4.1.1. ...

  5. python 判断是字母的多种方法

    方法一:isalpha() "a".isalpha()   方法二:string.letters string.uppercase  import string  s=" ...

  6. 后盾网lavarel视频项目---3、lavarel中子控制器继承父控制器以判断是否登录

    后盾网lavarel视频项目---3.lavarel中子控制器继承父控制器以判断是否登录 一.总结 一句话总结: 在common控制器的构造方法中验证登录中间件,其它的控制器继承common控制器 p ...

  7. 何为受控组件(controlled component)

    在 HTML 中,类似 , 和 这样的表单元素会维护自身的状态,并基于用户的输入来更新:当用户提交表单时,前面提到的元素的值将随表单一起被发送.但在 React 中会有些不同,包含表单元素的组件将会在 ...

  8. Fiddlercore拦截并修改HTTPS链接的网页,实现JS注入

    原始出处:https://www.cnblogs.com/Charltsing/p/FiddlerCoreHTTPS.html Fiddlercore可以拦截和修改http的网页内容,代码在百度很多. ...

  9. python出现AttributeError: module ‘xxx’ has no attribute ‘xxx’错误时,两个解决办法

    运行python程序时,也许会出现这样的错误:AttributeError: module ‘xxx’ has no attribute ‘xxx’: 解决该错误有两种方法 1.手动安装该模块 2.检 ...

  10. leetcode 1两数之和

    使用哈希的方法:先将nums哈希表化,再遍历nums,寻找-nums[i]如果存在则为题目所求 class Solution { public: vector<int> twoSum(ve ...