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 ...
随机推荐
- Linux Centos7安装Oracle12c第二版本
环境: CentOS7@VMware12,分配资源:CPU:2颗,内存:4GB,硬盘空间:30GB Oracle12C企业版64位 下载地址:http://www.oracle.com/technet ...
- c++中%是什么意思?
两种意思:1.格式化字符串输出2.整数取余 1.目前printf支持以下格式的输出,例如:printf("%c",a):输出单个字符.printf("%d",a ...
- python SQLAchemy多外键关联
关联同一张表的两个字段 Customer表有2个字段都关联了Address表 创建表结构 orm_many_fk.py 只创建表结构 from sqlalchemy import Integer, F ...
- eclipse 出现 jar包找不到 问题记录
同事在下载maven私服项目的时候,自动更新失败.maven 一直提示 parent 更新失败但是其他的项目都是正常的,这就奇怪了. 最后 仔细查询后,发现是 同事在下载项目时候,项目是分clien ...
- idea maven打不了war包
开发的时候打不了war包,原因是 web.xml有问题或者是在idea里面webroot没有作为web引用, 添加之后WebRoot上面有个地球标志 就ok了
- c# FTP操作类(转)
using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Net ...
- Unable to create a constant value of type 'System.Object'. Only primitive types or enumeration types are supported in this context.
代码如下: var query = from s in db.LoginUserServices join ss in db.Services on s.ServiceType equals ss.C ...
- CountDownLatch的简单使用
from https://www.jianshu.com/p/cef6243cdfd9 1.CountDownLatch是什么? CountDownLatch是一个同步工具类,它允许一个或多个线程一直 ...
- zt C++标准库set类型
C++标准库set类型 分类: C++编程语言 2012-11-06 10:53 909人阅读 评论(0) 收藏 举报 目录(?)[-] 在set中添加元素 从set中获取元素 set容器只是单纯的键 ...
- Linux下XAMPP的部署实战
上传源码文件 rz -be 下载xampp安装包wget http://sourceforge.net/projects/xampp/files/XAMPP%20Linux/5.5.28/xampp- ...