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

  1. 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[]; ][ ...

  2. Codeforces Round #487 (Div. 2) 跌分有感

    又掉分了 这次的笑话多了. 首先,由于CF昨天的比赛太早了,忘记了有个ER,比赛开始半个小时才发现. 于是只能今天了. 嗯哈. 今天这场也算挺早的. 嗯嗯,首先打开A题. 草草看了一遍题意,以为不是自 ...

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

  4. Codeforces Round #487 (Div. 2) E. A Trance of Nightfall (矩阵优化)

    题意 有一个平面 , 给你 \(n\) 个点构成一个点集 \(S\) , 一开始可以选择一个平面上任意点 \(P\) . 存在一种操作 : 1 选择一条至少 通过 \(S\) 中任意两个点以及 \(P ...

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

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

  7. Codeforces Round #487 (Div. 2) C. A Mist of Florescence 构造

    题意: 让你构造一个 n∗mn*mn∗m 矩阵,这个矩阵由 444 种字符填充构成,给定 444 个整数,即矩阵中每种字符构成的联通块个数,n,mn,mn,m 需要你自己定,但是不能超过505050. ...

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

  9. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

随机推荐

  1. 表单校验常用原生js库

    1.字符串去除左右空格继承形式// 除去左右空格String.prototype.Trim = function() { return this.replace(/(^\s*)|(\s*$)/g, & ...

  2. Java中的深拷贝和浅拷贝(转载)

    深拷贝(深复制)和浅拷贝(浅复制)是两个比较通用的概念,尤其在C++语言中,若不弄懂,则会在delete的时候出问题,但是我们在这幸好用的是Java.虽然java自动管理对象的回收,但对于深拷贝(深复 ...

  3. C++类继承--基类析构函数加上Virtual

    下面的内容要说明两个问题:1. 基类的析构函数为什么要加上Virtual--防止内存泄露 1. 基类虚构函数无virtual,派生类无法析构,会导致内存泄露 #include <stdio.h& ...

  4. 查看postgre都有哪些语句占用CPU

    查看占用CPU最多的几个postgresql ps aux | grep postgres | sort -n -r -k 3 | head -10 | awk '{print $2, $3}' 查看 ...

  5. javascprit form表单提交前验证以及ajax返回json

    1.今天要做一个手机验证码验证的功能.需求是前端页面点击发送 短信验证码,后台接收后通过ajax返回到前端,之后前端在提交时候进行验证.思路很简单,不过做的过程还是学到不少的东西. 1.ajax请求后 ...

  6. 如何编译 opencv3 和 opencv_contrib(Linux)

    本文以编译并安装OpenCV 3.3.0 为例,安装系统为 Linux x64 (Fedora 21),具体步骤如下: 1. 下载 Source code zip 压缩包 从下面网址,选择 openc ...

  7. HTML 水平线hr

    HTML 水平线 <hr /> 标签在 HTML 页面中创建水平线. hr 元素可用于分隔内容. 实例 <p>This is a paragraph</p> < ...

  8. MySql接口API函数综述

    C API函数概述 函数 描述 mysql_affected_rows() 返回上次UPDATE.DELETE或INSERT查询更改/删除/插入的行数. mysql_autocommit() 切换 a ...

  9. Java日志系统

    前言 各组件之间的关系: slf4j是The Simple Logging Facade for Java的简称,是一个简单日志门面抽象框架,它本身只提供了日志Facade API和一个简单的日志类实 ...

  10. Hibernate映射Map属性2

    Hibernate在映射Map属性时生成映射文件.需要注意的一些地方.下面是我的一个例子. Java类如下 public class NameAndNumber { private Integer i ...