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 grid 增加合计行
一.首先,easyui grid 的 showfooter 属性设置为 true $aplgrid.datagrid({ data: globalExpenseClaimForm.ExpenseCl ...
- 解决github访问过慢问题
解决github访问过慢问题 主要原因: DNS 自动解析较慢 http://github.global.ssl.fastly.net.ipaddress.com/#ipinfo 用文本编辑器打开ho ...
- 64位Navicat Premium-11.2.7(64bit)访问64位Oracle服务器
1 在windows 10 64位操作系统安装Navicat Premium-11.2.7(64bit). 2 在服务器安装64位的Oracle(win64_11gR2_database). 3 在h ...
- java面试题之----IO与NIO的区别
JAVA NIO vs IO 当我们学习了Java NIO和IO后,我们很快就会思考一个问题: 什么时候应该使用IO,什么时候我应该使用NIO 在下文中我会尝试用例子阐述java NIO 和IO的区别 ...
- calculate fraction by oracle
QUESTION:When you meet calculate fraction in oracle SOLUTION: 1.Check out their values respectively. ...
- 正则表达式 (python)
正则表达式 在正则表达式中,如果直接给出字符,就是精确匹配. 用\d可以匹配一个数字,\w可以匹配一个字母或数字,所以: '00\d'可以匹配'007',但无法匹配'00A': '\d\d\d'可以匹 ...
- 【Asp.Net MVC】asp.net mvc Model验证总结及常用正则表达式
转自:http://www.cnblogs.com/easy5weikai/p/3843131.html 关于Model验证官方资料: http://msdn.microsoft.com/zh-cn/ ...
- 条件独立(conditional independence) 结合贝叶斯网络(Bayesian network) 概率有向图 (PRML8.2总结)
转:http://www.cnblogs.com/Dzhouqi/p/3204481.html本文会利用到上篇,博客的分解定理,需要的可以查找上篇博客 D-separation对任何用有向图表示的概率 ...
- redis三节点sentinel部署
角色 ip port master 127.0.0.1 6379 slave-1 127.0.0.1 6380 slave-2 127. ...
- FBKVOController代码阅读
功能:对kvo机制进行封装,简化使用,简化内存管理: 要素:观察者.被观察者.处理函数. 模式:注册表模式: 机制:对象创建.注册管理.内存管理.处理机制转换: 其它:注册去重: kvo的管理机制: