Codeforces Round #590 (Div. 3)(e、f待补
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待补的更多相关文章
- Codeforces Round #590 (Div. 3) Editorial
Codeforces Round #590 (Div. 3) Editorial 题目链接 官方题解 不要因为走得太远,就忘记为什么出发! Problem A 题目大意:商店有n件商品,每件商品有不同 ...
- Codeforces Round #573 (Div. 1) 差F
Codeforces Round #573 (Div. 1) E 题意:二维平面上有 n 个点,你可以放至多 m 条直线使得 (0,0) 与每个点的连线至少与一条直线相交.求原点与所有直线的距离最小值 ...
- Codeforces Round #575 (Div. 3) 昨天的div3 补题
Codeforces Round #575 (Div. 3) 这个div3打的太差了,心态都崩了. B. Odd Sum Segments B 题我就想了很久,这个题目我是找的奇数的个数,因为奇数想分 ...
- Codeforces Round #590 (Div. 3) F
传送门 题意: 给出一个只含前\(20\)个字符的字符串,现在可以选择一段区间进行翻转,问区间中字符各不相同时,最长长度为多少. 思路: 首先,容易将题意转换为选择两个字符各不相同的区间,然后长度相加 ...
- Codeforces Round #541 (Div. 2) (A~F)
目录 Codeforces 1131 A.Sea Battle B.Draw! C.Birthday D.Gourmet choice(拓扑排序) E.String Multiplication(思路 ...
- Codeforces Round #532 (Div. 2):F. Ivan and Burgers(贪心+异或基)
F. Ivan and Burgers 题目链接:https://codeforces.com/contest/1100/problem/F 题意: 给出n个数,然后有多个询问,每次回答询问所给出的区 ...
- Codeforces Round #590 (Div. 3) E. Special Permutations
链接: https://codeforces.com/contest/1234/problem/E 题意: Let's define pi(n) as the following permutatio ...
- 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 ...
- Codeforces Round #600 (Div. 2)E F
题:https://codeforces.com/contest/1253/problem/E 题意:给定n个信号源,俩个参数x和s,x代表这个信号源的位置,s代表这个信号源的波及长度,即这个信号源可 ...
随机推荐
- Word:表格前添加新行 + 删除表格后的空行
本文适用于Word 2007 + Windows 7,造冰箱的大熊猫@cnblogs 2018/8/3 近日新学(百度到)两条新Word操作,记录下来以备查询 1.在表格前添加新行 场景:有没有遇到过 ...
- JS框架_(Vue.js)带有星期日期的数字时钟
百度云盘 传送门 密码:tv1v 数字时钟效果: <!doctype html> <html> <head> <meta charset="utf- ...
- 如何将JS中object转换为字符串
var obj = JSON.parse(str); //由JSON字符串转换为JSON对象 var last=obj.toJSONString(); //将JSON对象转化为JSON字符 或者 va ...
- MySQL + centos +主从复制
MYSQL(mariadb) MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可.开发这个分支的原因之一是:甲骨文公司收购了MySQL后,有将MySQL闭源的 ...
- 安卓项目集成objectbox-java数据库框架教程(非关系型)
objectbox数据库是greenrobot团队开发的全新非关系型数据库框架,该团队还开发过greenDao,EventBus等热门框架,objectbox可能是第一次听说,但是greenDao,E ...
- git 更改远程仓库地址,强行推送远程仓库
强行推送远程仓库 #把一个现有的工程拷贝一份 #去掉远程仓库关联 git remote rm origin #添加远程仓库关联 git remote add origin http://xxx.git ...
- 第九周学习总结&实验报告(7)
完成火车站售票程序的模拟. 要求: (1)总票数1000张; (2)10个窗口同时开始卖票; (3) 卖票过程延时1秒钟; (4)不能出现一票多卖或卖出负数号票的情 况 实验代码: package y ...
- DS博客作业08—课程总结
1.当初你是如何做出选择计算机专业的决定的? 开始时我选择的专业就是网络/物联网,计算机专业是一个充满创造性的专业 2.对比开篇博客,哪些方面还存在哪些不足? 这个人就像戏台上的老将军,全身插满fla ...
- charts_03
table 数值获取: 1.http://www.w3school.com.cn/jsref/dom_obj_all.asp 2.http://blog.csdn.net/xs_zgsc/articl ...
- HTML控件 隐藏
div的visibility可以控制div的显示和隐藏,但是隐藏后页面显示空白: style="visibility: none;" document.getElementById ...