Educational Codeforces Round 105 (Rated for Div. 2)
A. ABC String
题目:就是用‘(’和‘)’来代替A,B,C并与之对应,问是不是存在这样的对应关系使得'('和‘)'正好匹配
思路:第一个和最后一个字母是确定的左括号或者是右括号,这样就还剩下一个字母没有进行讨论,然后假设一下,分成两种情况进行计算,只要有一种情况满足就好
代码:

1 #include<iostream>
2 #include<cstdio>
3 #include<cmath>
4 #include<algorithm>
5 #include<cstring>
6 using namespace std;
7 int main(){
8 int t;
9 scanf("%d",&t);
10 while(t--){
11 char s[100];
12 getchar();
13 scanf("%s",&s);
14 int a=0,b=0,c=0;
15 int z=0,y=0;
16 int flag1=0,flag2=0;
17 for(int i=0;i<strlen(s);i++){
18 if(s[i]==s[0]){
19 z++;
20 }else if(s[i]==s[strlen(s)-1]){
21 y++;
22 }else{
23 z++;
24 }
25 if(y>z){
26 flag1=1;
27 }
28 }
29 if(z!=y){
30 flag1=1;
31 }
32 z=0;
33 y=0;
34 for(int i=0;i<strlen(s);i++){
35 if(s[i]==s[0]){
36 z++;
37 }else if(s[i]==s[strlen(s)-1]){
38 y++;
39 }else{
40 y++;
41 }
42 if(y>z){
43 flag2=1;
44 }
45 }
46 if(z!=y){
47 flag2=1;
48 }
49 z=0;
50 y=0;
51 if(flag1==1&&flag2==1){
52 printf("NO\n");
53 }else{
54 printf("YES\n");
55 }
56
57
58 }
59 }
B. Berland Crossword
题目:给定一个n×n的方格,起初都是空白的,给定第一行最后一行第一列最后一列会有多少个空格需要涂黑,问是不是有满足条件的涂色方法满足要求
思路:影响排布的只有四个角上的代码,那么就直接进行模拟从0-1四个角,只要有一个满足条件就可以,
代码:

1 #include<iostream>
2 #include<cstdio>
3 #include<cmath>
4 #include<algorithm>
5 #include<cstring>
6 using namespace std;
7 int n,u,r,l,d;
8 int check(int i,int j,int k,int z){
9 if(i+j+n-2<u||u<i+j) return 0;
10 if(j+k+n-2<r||r<j+k) return 0;
11 if(z+k+n-2<d||d<z+k) return 0;
12 if(i+z+n-2<l||l<i+z) return 0;
13 return 1;
14 }//问题出在了全局变量和局部变量的问题上
15 int main(){
16 int t;
17 scanf("%d",&t);
18 while(t--){
19 // int n,u,r,l,d;
20 int uu=0,rr=0,ll=0,dd=0;
21 int flag=0;
22 scanf("%d %d %d %d %d",&n,&u,&r,&d,&l);
23 for(int i=0;i<=1;i++){
24 for(int j=0;j<=1;j++){
25 for(int k=0;k<=1;k++){
26 for(int z=0;z<=1;z++){
27 if(check(i,j,k,z)==1) flag=1;
28 }
29 }
30 }
31 }
32 if(flag==1){
33 printf("YES\n");
34 }else{
35 printf("NO\n");
36 }
37 }
38 }
这套题告诉我最多的就是,有些变化少的东西,规律找不到就可以从头考虑是不是该进行模拟,然后一个一个的进行判断,毕竟很多东西不是总存在规律,而且有的题目范围也不是很大
Educational Codeforces Round 105 (Rated for Div. 2)的更多相关文章
- Educational Codeforces Round 64 (Rated for Div. 2)题解
Educational Codeforces Round 64 (Rated for Div. 2)题解 题目链接 A. Inscribed Figures 水题,但是坑了很多人.需要注意以下就是正方 ...
- [Educational Codeforces Round 81 (Rated for Div. 2)]E. Permutation Separation(线段树,思维,前缀和)
[Educational Codeforces Round 81 (Rated for Div. 2)]E. Permutation Separation(线段树,思维,前缀和) E. Permuta ...
- Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship
Problem Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...
- Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)
Problem Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...
- Educational Codeforces Round 43 (Rated for Div. 2)
Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...
- Educational Codeforces Round 35 (Rated for Div. 2)
Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...
- Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings
Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings 题目连接: http://cod ...
- Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes
Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes 题目连接: http://code ...
- Educational Codeforces Round 63 (Rated for Div. 2) 题解
Educational Codeforces Round 63 (Rated for Div. 2)题解 题目链接 A. Reverse a Substring 给出一个字符串,现在可以对这个字符串进 ...
随机推荐
- filecoin今日价格,filecoin币价估值,filecoin币会涨到多少钱
filecoin今日价格,截止 2021 年 3 月 17 日 9 时,filecoin价格为 63.8939 美元,约合人民币 415.69 元.流通市值约 416.2 亿人民币,总市值达到 831 ...
- 攻防世界 reverse babymips
babymips XCTF 4th-QCTF-2018 mips,ida中想要反编译的化需要安装插件,这题并不复杂直接看mips汇编也没什么难度,这里我用了ghidra,直接可以查看反编译. 1 ...
- XML数据持久化学习笔记
一.XML基础语法 1.XML结构:XML是一种树结构的文本 2.XML注释:格式:<!--在其中书写注释-->,在注释中可以单行注释也可以多行注释 3.固定内容:<?xml ver ...
- 通过《第一行代码》学习 Android 开发
第一行代码 Android --第 2 版-- 郭霖 著 第 1 章:开始启程--你的第一行 Android 代码 •1.2 手把手带你搭建开发环境 Android Studio 的安装及配置 A ...
- Hystrix熔断原理
Netflix的开源组件Hystrix的流程: 图中流程的说明: 将远程服务调用逻辑封装进一个HystrixCommand. 对于每次服务调用可以使用同步或异步机制,对应执行execute()或que ...
- 这可能是最容易理解的 Go Mutex 源码剖析
Hi,大家好,我是 haohongfan. 上一篇文章<一文完全掌握 Go math/rand>,我们知道 math/rand 的 global rand 有一个全局锁,我的文章里面有一句 ...
- Java与Python中的‘%’运算符意义一样么?
1. 取余与取模 百度百科对于取模运算做了如下定义: 对于整型数a,b来说,取模运算或者求余运算的方法都是: 1.求 整数商: c = [a/b]; 2.计算模或者余数: r = a - c*b. 求 ...
- 18. VUE created 方法作用
一般可以在created函数中调用ajax获取页面初始化所需的数据. 实例的生命周期: 每个 Vue 实例在被创建之前都要经过一系列的初始化过程.例如,实例需要配置数据观测(data observer ...
- git推送代码报错:fatal: The current branch master has no upstream branch. To push the current branch and set the remote as upstream
情景再现 远程新建仓库,然后本地 git bash执行以下代码 git init git add . git commit -m 'xxx' git remote add origin https:/ ...
- Mybatis3源码笔记(八)小窥MyBatis-plus
前言 Mybatis-Plus是一个 MyBatis增强工具包,简化 CRUD 操作,在 MyBatis 的基础上只做增强不做改变,为简化开发.提高效率而生,号称无侵入,现在开发中比较常用,包括我自己 ...