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的更多相关文章

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

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

  2. Codeforces Round #590 (Div. 3)

    A. Equalize Prices Again 题目链接:https://codeforces.com/contest/1234/problem/A 题意:给你 n 个数 , 你需要改变这些数使得这 ...

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

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

  4. 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 ...

  5. Codeforces Round #590 (Div. 3) C. Pipes

    链接: https://codeforces.com/contest/1234/problem/C 题意: You are given a system of pipes. It consists o ...

  6. 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 ...

  7. 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 ...

  8. Codeforces Round #590 (Div. 3)(e、f待补

    https://codeforces.com/contest/1234/problem/A A. Equalize Prices Again #include<bits/stdc++.h> ...

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

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

随机推荐

  1. 【ARM-Linux开发】如何使用opkg在RicoBoard上在线安装软件包

    类似于debian的apt-get,Redhat的yum类似,嵌入式Linux平台可以使用opkg实现在线安装软件包的功能,在我们提供的matrix文件系统中,已经包含了opkg工具,但是还没有配置一 ...

  2. UIPath工具里面如何入力一览里面的数据

    问题描述: UIpath工具如何在网页里面入力一览多条的数据.例如:某个公司里面在自己的内部员工管理的软件里面手动入力公司员工的所有信息之后反馈到数据库当中. 解决方法: UIpath工具来入力数据, ...

  3. 【AtCoder】diverta 2019 Programming Contest 2

    diverta 2019 Programming Contest 2 A - Ball Distribution 特判一下一个人的,否则是\(N - (K - 1) - 1\) #include &l ...

  4. Robot 安装

    安装一个测试环境的 下载python27 升级pip E:\Python27\python -m pip install --upgrade pip 安装robotramework E:\Python ...

  5. SysTick 定时实验(非中断)

    实验目的:利用 SysTick 产生 1s 的时基,LED 以 1s 的频率闪烁. 编程要点 1.设置重装载寄存器的值 2.清除当前数值寄存器的值 3.配置控制与状态寄存器 过程 我们创建了两个文件: ...

  6. MyBatis_01 框架

    Mybatis概述 Mybatis是什么 Mybatis是一个持久层框架.   Mybatis的作用 Mybatis是一个持久层框架,当然作用就是操作数据库的(增删改查).   为什么需要学习Myba ...

  7. (三)CXF之处理输入参数与输出类型为复杂类型的webService服务

    一.需求 调用webService服务,把用户名和密码封装为用户对象作为参数,返回该用户所用友的角色列表. 二.发布服务 2.1 编写服务接口 @WebService public interface ...

  8. Java HeapSort

    Java HeapSort /** * <html> * <body> * <P> Copyright 1994-2018 JasonInternational & ...

  9. c#基础知识梳理(三)

    上期回顾 - https://www.cnblogs.com/liu-jinxin/p/10824638.html 一.方法 一个方法是把一些相关的语句组织在一起,用来执行一个任务的语句块.每一个 C ...

  10. python实现暴力破解

    import urllib2 import urllib import cookielib import threading import sys import Queue from HTMLPars ...