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\)个字符的字符串,现在可以选择一段区间进行翻转,问区间中字符各不相同时,最长长度为多少. 思路: 首先,容易将题意转换为选择两个字符各不相同的区间,然后长度相加 ...
随机推荐
- redis 启动配置文件加载报错 service redis does not support chkconfig
# chkconfig: # description:Redis is a persistent key-value database 网上资料 上面的注释的意思是,redis服务必须在运行级2,3, ...
- php csv 简单的导入
if($act == 'user_upload_do'){ global $db; $filename = $_FILES['file']['tmp_name']; if (empty ($filen ...
- NET CORE与Spring Boot
NET CORE与Spring Boot 本文分别说明.NET CORE与Spring Boot 编写控制台程序应有的“正确”方法,以便.NET程序员.JAVA程序员可以相互学习与加深了解,注意本文只 ...
- requirejs r.js 打包报错paths fallback not supported in optimizer please provide a build config path override for jquery
错误原因: 改为:
- input文本框禁用历史选择
这里常用的场景是日期控件使用时,下面这个就很难看了 在input中添加autocomplete="off"就可以了 <input type="text" ...
- 创建SSH密钥
Step1: 检查SSH密钥 首先,打开终端,输入以下指令,查看是否已经生成SSH密钥. cd ~/.ssh ls # Lists the files in your .ssh directory 在 ...
- 在airflow的BashOperator中执行docker容器中的脚本容易忽略的问题
dag模板 from airflow import DAG from airflow.operators.bash_operator import BashOperator from airflow. ...
- 事务的ACID
事务提供一种机制将一个活动涉及的所有操作纳入到一个不可分割的执行单元,组成事务的所有操作只有在所有操作均能正常执行的情况下方能提交,只要其中任一操作执行失败,都将导致整个事务的回滚. 简单地说,事务提 ...
- ThreadLocal内存泄漏真因探究(转)
出处: 链接:https://www.jianshu.com/p/a1cd61fa22da ThreadLocal原理回顾 ThreadLocal的原理:每个Thread内部维护着一个ThreadLo ...
- (六)CXF之自定义拦截器
一.需求分析 客户端在调用服务端的方法时,需要进行用户名和密码验证.此时分为: 客户端请求的时候,要发送用户名密码到服务端 服务端检验用户名密码. 二.案例 前提:本章案例是基于前一章节的例子进一步讲 ...