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 给出一个字符串,现在可以对这个字符串进 ...
随机推荐
- [set]JZOJ 5821 手机信号
Description
- vue-i18n 国际化语言切换
vue-i18n 用于前端vue项目中,需要多语言切换的场景 安装方法(npm) npm install vue-i18n 简单使用 1.在vue项目的main.ts文件中实例化 i18n imp ...
- Python fire库使用
1.前要fire是python中用于生成命令行界面(Command Line Interfaces, CLIs)的工具 不需要做任何额外的工作,只需要从主模块中调用fire.Fire() 它会自动将你 ...
- 利用别名切换索引流程Elasticsearch 7.7
背景 公司里面现在有es集群,由于时间过长,es集群中的某个索引过大但是未删除,一直在写入的情况下,昨天写入突然停止了,发现是索引超时的问题,这时想到通过创建一个新的索引来进行索引切换 操作 es 集 ...
- 第28 章 : 理解容器运行时接口 CRI
理解容器运行时接口 CRI CRI 是 Kubernetes 体系中跟容器打交道的一个非常重要的部分.本文将主要分享以下三方面的内容: CRI 介绍 CRI 实现 相关工具 CRI 介绍 在 CRI ...
- 13个精选的React JS框架
如果你正在使用 React.js 或 React Native 创建用户界面,可以试一试本文推荐的这些框架. React.js 和 React Native 是流行的用户界面(UI)开发平台,且都是开 ...
- HCL实验8:NAT搭建私有网络
NAT 通过NAT技术,进行私有网络的搭建 拓扑图 先对路由器的端口进行配置 R1 [H3C]sys R1 [R1]INT G0/0 [R1-GigabitEthernet0/0]ip address ...
- php添加excel更新数据表数据
公司有个需求,是用excel更新数据的,把错误的行列放到一个数组返回出来,正常的数据则插入,且返回数量 1.先需要引入phpspreadsheet,这里使用composer 安装 composer r ...
- ubuntu apt出错
whitedream@ubuntu:~$ sudo apt-get update Reading package lists... Done E: Could not get lock /var/li ...
- mp4视频中插入文字
最近接到一个需求,需要往mp4中动态插入文字,并且mp4中的乌云能在文字上有飘动的效果,一开始想用canvas,但是由于本人经验不足,没什么思路,看到css3有一个属性:mix-blend-mode, ...