Codeforces Round #590 (Div. 3) 万恶的自己WAC
C题:一道简单的C题卡了半天,我太菜了
题意:给你一个n*2的矩阵,每个位置有一个数字,对应一种管道,要求通道可不可以从左上通到右下
由提议可以看出,1,2对应的是直管道,3,4,5,6对应弯管道,只有弯管道成对才可以换行,直管道只能换列
只需直管道的时候往右走,弯管的时候判断一下对应的下一行情况,同时弯管就换行,不是就输出“NO”
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm> using namespace std;
typedef long long ll;
string s[]; int main()
{
int q;
cin >> q;
while(q--)
{
int n;
bool flag =false;
cin >> n;
cin >> s[]>>s[];
int num =;
int i=;
int j=;
while(i<n)
{
if(s[j][i]<'')i++;
else if(s[j][i]>'')
{
j^=;
if(s[j][i]>'')i++;
else{
break;
}
}
}
if(j==&&i==n)
{
cout <<"YES"<<endl;
}
else{
cout <<"NO"<<endl;
}
}
return ;
}
D题
题意:给你一个字符串,然后有q次操作,操作分为两种:第一种操作是改变一个位置的字母为另一个指定字母;第二种操作是查询区间(L~R)上有多少个不同的字符
思路:第一想法是线段树模板,线段树一直还没看,也没有看板子,当时就没有做,后来补题看别人交的代码,发现竟然可以用set来优化查询,果然我就连STL都不会用,留下菜的泪水。。。。。。。
就是我们字母总共就只有26个,我就开26个set来存,每个字母的位置,修改时只需将那个点的字母去掉那个位置,在给定的字母里面加上这个为位置,查询时就将26个字母都查一遍
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <set>
using namespace std;
typedef long long ll; int main()
{
string s;
set<int>p[];
cin >> s;
for(int i=;i<s.size();i++)
{
p[s[i]-'a'].insert(i+);
}
int q;
cin >> q;
while(q--)
{
int a;
scanf("%d",&a);
if(a==){
int b;
char cc[];
scanf("%d",&b);
scanf("%s",cc);
//cout <<cc[0]<<endl;
p[s[b-]-'a'].erase(b);
s[b-]=cc[];
p[cc[]-'a'].insert(b); }
else{
int l,r;
int ans = ;
scanf("%d%d",&l,&r);
for(int i=;i<;i++)
{
if(p[i].size())
{
auto j =p[i].lower_bound(l);
if(*j<=r&&j!=p[i].end())ans++;
}
}
cout << ans<<endl;
}
}
return ;
}
Codeforces Round #590 (Div. 3) 万恶的自己WAC的更多相关文章
- Codeforces Round #590 (Div. 3) Editorial
Codeforces Round #590 (Div. 3) Editorial 题目链接 官方题解 不要因为走得太远,就忘记为什么出发! Problem A 题目大意:商店有n件商品,每件商品有不同 ...
- Codeforces Round #590 (Div. 3)
A. Equalize Prices Again 题目链接:https://codeforces.com/contest/1234/problem/A 题意:给你 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 #590 (Div. 3) C. Pipes
链接: https://codeforces.com/contest/1234/problem/C 题意: You are given a system of pipes. It consists o ...
- Codeforces Round #590 (Div. 3) B2. Social Network (hard version)
链接: https://codeforces.com/contest/1234/problem/B2 题意: The only difference between easy and hard ver ...
- Codeforces Round #590 (Div. 3) A. Equalize Prices Again
链接: https://codeforces.com/contest/1234/problem/A 题意: You are both a shop keeper and a shop assistan ...
- Codeforces Round #590 (Div. 3)(e、f待补
https://codeforces.com/contest/1234/problem/A A. Equalize Prices Again #include<bits/stdc++.h> ...
- Codeforces Round #590 (Div. 3) F
传送门 题意: 给出一个只含前\(20\)个字符的字符串,现在可以选择一段区间进行翻转,问区间中字符各不相同时,最长长度为多少. 思路: 首先,容易将题意转换为选择两个字符各不相同的区间,然后长度相加 ...
随机推荐
- 【ARM-Linux开发】Wi-Fi 应用工具wpa_supplicant
wpa_supplicant是一个跨平台的无线安全管理软件,这里需要用它来对无线网络进行配置,wpa_supplicant相关工具已经移植好,包含在我们提供的文件系统中. 配置无线网络 wpa_sup ...
- 安卓中listview中性能优化的处理
1.在adapter中的getView方法中尽量少使用逻辑 不要在你的getView()中写过多的逻辑代码,我们能够将这些代码放在别的地方.比如: 优化前的getView(): @Override p ...
- C++中pair详解
pair是定义在<utility>中的生成特定类型的模板,它的作用是把一组数据合并为一体,实际上是一个拥有两个成员变量的struct. 创建一个pair对象时,需要提供两个数据类型(不要求 ...
- 乐字节Java循环:循环控制和嵌套循环
乐字节小乐上次讲完了Java反射,接下来小乐给大家讲述Java循环. 循环有以下四部分: 一.循环控制 1. do..while 直到型 ( 先执行后判断) ,结构为: 先执行循环体,后判断布尔表达式 ...
- [转帖]2018年SaaS行业收入结构及未来发展预测[图]
2018年SaaS行业收入结构及未来发展预测[图] http://www.chyxx.com/industry/201908/774792.html 2019年08月23日 14:34:47字号:T| ...
- Django mysql-client
sudo apt-get install libmysqlclient-dev 报错,mysqlclient 没有安装 :实际已经安装,这是因为mysql安装时没有安装好 https://www.cn ...
- 脉脉的一道网红Java面试题
题目如下: public class Test { public static void main(String[] args) { int a = 10; int b = 10; // 需要在met ...
- 【C++札记】类的分离式写法
介绍 类的分离式写法,使得代码更加规范,增强了阅读性. 分离式写法的规则: 1.类的变量:写在类的里面 2.成员函数:类中写函数的声明,函数的定义写在类体外. 3.写在类外函数定义时,类名前加限定(O ...
- 版本管理——Git和SVN的介绍及其优缺点
版本管理 概念:版本管理是软件配置管理的基础,它管理并保护开发者的软件资源. 好处:可以保留我们的历史版本,在代码开发到一半的时候,不至于无故丢失,还可以查看BUG的来龙去脉. 版本管理种类: ...
- Python senium 中页面属性
1.通过id定位元素2.通过class_name定位元素3.通过tag_name定位元素4.通过name定位元素5.通过link文字精确定位元素6.通过link文字模糊定位元素7.通过CSS定位元素8 ...