【Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) A】 Doggo Recoloring
【链接】 我是链接,点我呀:)
【题意】
你可以把出现次数大于1的颜色换成其他颜色。
问你最后能不能全都变成同一种颜色
【题解】
判断一下有没有出现次数大于1的就好。
有的话。显然可以一直用它变颜色。
特判n=1的情况。就好。
【代码】
#include <bits/stdc++.h>
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define lson l,mid,rt<<1
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rs(x) scanf("%s",x)
#define rson mid+1,r,rt<<1|1
using namespace std;
const double pi = acos(-1);
const int dx[4] = {0,0,1,-1};
const int dy[4] = {1,-1,0,0};
int n;
string s;
int a[300];
int main(){
#ifdef LOCAL_DEFINE
freopen("rush_in.txt", "r", stdin);
#endif
cin >> n;
cin >> s;
for (int i = 0;i < n;i++) a[s[i]-'a'+1]++;
for (int i = 1;i <= 26;i++)
if (a[i]>1){
cout<<"Yes"<<endl;
return 0;
}
if (n==1){
cout<<"Yes"<<endl;
return 0;
}
cout<<"No"<<endl;
return 0;
}
【Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) A】 Doggo Recoloring的更多相关文章
- 【Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) C】
[链接] 我是链接,点我呀:) [题意] 给你一个字符串s. 让你在其中的某一些位置进行操作.. 把[1..i]和[i+1..n]翻转. 使得里面01交替出现的那种子串的长度最长. [题解] 可以用a ...
- 【Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) B】Weakened Common Divisor
[链接] 我是链接,点我呀:) [题意] 给你n个数对(ai,bi). 让你求一个大于1的数字x 使得对于任意的i x|a[i] 或者 x|b[i] [题解] 求出第一个数对的两个数他们有哪些质因子. ...
- D. Recovering BST Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)
http://codeforces.com/contest/1025/problem/D 树 dp 优化 f[x][y][0]=f[x][z][1] & f[z+1][y][0] ( gcd( ...
- Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) -B C(GCD,最长连续交替序列)
B. Weakened Common Divisor time limit per test 1.5 seconds memory limit per test 256 megabytes input ...
- Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) B. Weakened Common Divis
题目链接 让你找一个数,使得这个数,可以被每个二元组的两个数中的一个数整除. 先将第一个二元组的两个数质因数分解一下,分解的质数加入set中,然后,对剩下的n-1个二元组进行遍历,每次遍历到的二元组对 ...
- Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)
A : A. Doggo Recoloring time limit per test 1 second memory limit per test 256 megabytes input stand ...
- Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)-C. Plasticine zebra
问了学长,感觉还是很迷啊,不过懂了个大概,这个翻转操作,实质不就是在序列后面加上前面部分比如 bw | wwbwwbw 操作过后 wbwbwwbww 而 bw | wwbwwbwbw 这样我们就知道 ...
- Codeforces Round #505 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final) 题解
真心简单的一场比赛 就是坑比较多(自己太蠢) A是一个水题 3分钟的时候过了 B也是一个比较简单的题 类似的套路见得多了 但是我当时可能比较困 想了一会才想出来 19分钟的时候过掉了 C同样很显然 性 ...
- E - Down or Right Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)
http://codeforces.com/contest/1023/problem/E 交互题 #include <cstdio> #include <cstdlib> #i ...
随机推荐
- MVVM设计模式基础知识--ICommand接口
命令是 Windows Presentation Foundation (WPF) 中的输入机制,它提供的输入处理比设备输入具有更高的语义级别. 命令有若干用途: 第一个用途是将语义以及调用命令的对象 ...
- margin 百分比是按參照物来计算滴 不知道吧?
<style> #demo{ margin: 0 auto; width: 1000px; height: 500px; background: #eee; overflow: hidde ...
- 分析AWR报告
1.AWR报告头信息 DB Name :数据库名字 DBid: 数据库id Elapsed:采样时间段 DB Time:用户操作花费的时间,不包括Oracle后台进程消耗的时间 DB Time远小于E ...
- [PHP] Ecstore 开发学习资源
一.ECOS框架图 二.学习资源链接 PHP之窗 http://www.phpwindow.com/ ECOS百科大全 http://www.ec-os.net/doc.html
- c语言递归讲解分析
C语言允许函数调用它自己,这种调用的过程称为"递归(recursion)" 举例说明,如下代码: #include <stdio.h> void up_and_down ...
- Dvwa安装,配置(Linux)
文章演示使用系统:CenTOS7 一:搭建LAMP环境 使用XAMPP安装部署,下载地址:https://www.apachefriends.org/download.html 1.1:赋予账号对XA ...
- LeetCode Weekly Contest 25
1. 507. Perfect Number 显然小于2的都不满足(尤其是负数的情况),进一步,显然质数都不满足,所以小于4的数,直接return false. 然后依次暴力枚举判断到sqrt(n), ...
- linux下创建公钥
# linux下创建公钥 链接地址:https://www.cnblogs.com/ibyte/p/6086630.html 示例: scp -r /home/yutang/.ssh/id_rsa.p ...
- Linux下实现视频读取
V4L(video4linux是一些视频系统,视频软件.音频软件的基础,经常时候在需要采集图像的场合,如视频监控,webcam,可视电话,经常使用在embedded linux中是linux嵌入式开发 ...
- [Offer收割]编程练习赛42
对局匹配 直接贪心 #pragma comment(linker, "/STACK:102400000,102400000") #include<stdio.h> #i ...