Codeforces Round #487 (Div. 2)
A. A Blend of Springtime(暴力/模拟)
题目大意
给出$n$个花,每个点都有自己的颜色,问是否存在连续大于等于三个花颜色均不相同
sol
直接模拟判断即可
#include<cstdio>
#include<cstring>
using namespace std;
const int MAXN = ;
inline int read() {
char c = getchar(); int x = , f = ;
while(c < '' || c > '') {if(c == '-') f = -; c = getchar();}
while(c >= '' && c <= '') x = x * + c - '', c = getchar();
return x * f;
}
int a[MAXN][];
char s[MAXN];
int main() {
#ifdef WIN32
//freopen("a.in", "r", stdin);
#endif
scanf("%s", s + );
int N = strlen(s + );
for(int i = ; i <= N; i++) {
if(s[i] == 'A') a[i - ][] = , a[i + ][] = , a[i][] = ;
if(s[i] == 'B') a[i - ][] = , a[i + ][] = , a[i][] = ;
if(s[i] == 'C') a[i - ][] = , a[i + ][] = , a[i][] = ;
}
for(int i = ; i <= N; i++) {
if(a[i][] == && a[i][] == && a[i][] == ) {
puts("Yes"); return ;
}
}
puts("No");
return ;
}
A
B. A Tide of Riverscape(暴力/模拟)
题目大意
给定一段序列,由$“1”,“0”,“.”$组成,其中$.$代表不确定是$“1”$还是$“0”$,
给定一个$p$,问这个序列是否满足对于$i + P <= N$的$i$,存在$i$与$i+P$位置的字符不同。
sol
大力特判两个位置是否可以满足
#include<cstdio>
#include<cstring>
using namespace std;
const int MAXN = ;
inline int read() {
char c = getchar(); int x = , f = ;
while(c < '' || c > '') {if(c == '-') f = -; c = getchar();}
while(c >= '' && c <= '') x = x * + c - '', c = getchar();
return x * f;
}
int N, P;
char s[MAXN];
#define GG puts("No"); return 0;
int main() {
#ifdef WIN32
//freopen("a.in", "r", stdin);
#endif
scanf("%d %d", &N, &P);
scanf("%s", s + );
bool flag = ;
for(int i = ; i <= N - P; i++) {
if(s[i] == '') {
if(s[i + P] == '') {flag = ; break;}
if(s[i + P] == '.') {s[i + P] = ''; flag = ; break;}
}
if(s[i] == '') {
if(s[i + P] == '') {flag = ; break;}
if(s[i + P] == '.') {s[i + P] = ''; flag = ; break;}
}
if(s[i] == '.') {
if(s[i + P] == '') {s[i] = ''; flag = ; break;}
if(s[i + P] == '') {s[i] = ''; flag = ; break;}
if(s[i + P] == '.') {s[i] = ''; s[i + P] = ''; flag = ; break;}
}
}
if(flag == ) {puts("No"); return ;}
for(int i = ; i <= N; i++) {
if(s[i] == '.') putchar('');
else putchar(s[i]);
}
return ;
}
B
C. A Mist of Florescence(构造)
题目大意
给出四个数$a,b,c,d$,构造一个矩阵满足$“A”,"B","C","D"$对应联通块的数量为$a,b,c,d$
sol
考场上没想出来,思维太局限了,看到$n,m<=50$但是没有把它作为突破口。
正解非常刁钻,一图解千愁,不过我写的和正解不太一样,我是每三个空格放一个。
#include<cstdio>
using namespace std;
const int MAXN = ;
inline int read() {
char c = getchar(); int x = , f = ;
while(c < '' || c > '') {if(c == '-') f = -; c = getchar();}
while(c >= '' && c <= '') x = x * + c - '', c = getchar();
return x * f;
}
int mp[MAXN][MAXN];
int color[MAXN] = {, , , , };
char ans[MAXN] = {' ', 'A', 'B', 'C', 'D'};
int a[];
int main() {
#ifdef WIN32
//freopen("a.in", "r", stdin);
#endif
//int a = read() - 1, b = read() - 1, c = read() - 1, d = read() - 1;
for(int i = ; i <= ; i++) a[i] = read() - ;
for(int i = ; i <= ; i++)
for(int k = color[i] * + ; k <= color[i] * + ; k++)
for(int j = ; j <= ; j++)
mp[k][j] = color[i] + ; /* for(int i = 1; i <= MAXN - 1; i++, puts(""))
for(int j = 1; j <= MAXN - 1; j++)
printf("%d ", mp[i][j]); */
for(int i = ; i <= ; i++) {
int num = a[i];
for(int k = color[ - i] * + ; num > && k <= color[ - i] * + ; k++) {
for(int j = + (k & ); num > && j <= ; j += )
mp[k][j] = color[i] + , num--;
}
}
printf("48 50\n");
for(int i = ; i <= ; i++, puts(""))
for(int j = ; j <= ; j++)
putchar(ans[mp[i][j]]);
return ;
}
C

总结


又是两题滚粗,不过值得庆幸的是前两题都是1A,T3没做出来确实比较遗憾
以前从来没做过构造题也是原因之一
感觉T3这种题是有点套路的,最重要的是不要相信它给的样例!!!
然后应该把思维打开,多在宏观角度构造构造。
Codeforces Round #487 (Div. 2)的更多相关文章
- Codeforces Round #487 (Div. 2) C - A Mist of Florescence
C - A Mist of Florescence 把50*50的矩形拆成4块 #include<bits/stdc++.h> using namespace std; ],b[]; ][ ...
- Codeforces Round #487 (Div. 2) 跌分有感
又掉分了 这次的笑话多了. 首先,由于CF昨天的比赛太早了,忘记了有个ER,比赛开始半个小时才发现. 于是只能今天了. 嗯哈. 今天这场也算挺早的. 嗯嗯,首先打开A题. 草草看了一遍题意,以为不是自 ...
- C. A Mist of Florescence ----- Codeforces Round #487 (Div. 2)
C. A Mist of Florescence time limit per test 1 second memory limit per test 256 megabytes input stan ...
- Codeforces Round #487 (Div. 2) E. A Trance of Nightfall (矩阵优化)
题意 有一个平面 , 给你 \(n\) 个点构成一个点集 \(S\) , 一开始可以选择一个平面上任意点 \(P\) . 存在一种操作 : 1 选择一条至少 通过 \(S\) 中任意两个点以及 \(P ...
- Codeforces Round #487 (Div. 2) A Mist of Florescence (暴力构造)
C. A Mist of Florescence time limit per test 1 second memory limit per test 256 megabytes input stan ...
- code forces Codeforces Round #487 (Div. 2) C
C. A Mist of Florescence time limit per test 1 second memory limit per test 256 megabytes input stan ...
- Codeforces Round #487 (Div. 2) C. A Mist of Florescence 构造
题意: 让你构造一个 n∗mn*mn∗m 矩阵,这个矩阵由 444 种字符填充构成,给定 444 个整数,即矩阵中每种字符构成的联通块个数,n,mn,mn,m 需要你自己定,但是不能超过505050. ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
随机推荐
- EasyUI combobox 多选及回显赋值
multiple boolean 决定是否支持多项选择. $('#cc').combobox({ url:'combobox_data.json', multiple:true, //支持多选 val ...
- 项目经验:GIS<MapWinGIS>建模第三天
记录下GIS工程进展
- VC++ 6.0如何创建与调用动态链接库
原文:http://blog.csdn.net/wanghaihao_1/article/details/51098451 1.静态链接库与动态链接库区别: 静态链接库:lib中的指令被直接包含在最终 ...
- Spring boot Jackson基本演绎法&devtools热部署
1.针对POJO中的User类添加一些注解,使其某些数据不显示或者格式化某些数据类型,如下图: 2.启动Application,然后进入浏览器访问http://localhost:8080/user/ ...
- HTML 5篇(持续更新)
1.sessionStorage .localStorage 和 cookie 之间的区别 (一)共同点:都是保存在浏览器端,且同源的. (二)区别:cookie数据始终在同源的http请求中携带(即 ...
- C# 3.0-c#5.0 变化
最近发现对于C#的使用水平一只停留在3.0的程度 对于4.0 5.0的新特性使用的很少,写一篇文章记录一下增加一下认识. C# 3.5 扩展方法 扩展方法所在的类和扩展方法必须是静态的 并且扩展方法第 ...
- Android之自定义View以及画一个时钟
https://www.2cto.com/kf/201509/443112.html 概述: 当Android自带的View满足不了开发者时,自定义View就发挥了很好的作用.建立一个自定义View, ...
- c# FTP操作类(转)
using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Net ...
- AJAX原生JavaScript写法
GET方式 //创建XMLHttpRequest对象,为考虑兼容性问题,老版本的 Internet Explorer (IE5 和 IE6)使用 ActiveX 对象 var ajax = windo ...
- 关于 Windows 7 语言包
在对IE浏览器进行多语言对应的时候,网页会检测当前系统的语言,来判断网页需要以哪种语言显示.但是,在给系统安装指定语言包时,可能会遇到安装失败的情况,原因就是需要在你的电脑上安装必需的基本语言包.请看 ...