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

  1. Educational Codeforces Round 64 (Rated for Div. 2)题解

    Educational Codeforces Round 64 (Rated for Div. 2)题解 题目链接 A. Inscribed Figures 水题,但是坑了很多人.需要注意以下就是正方 ...

  2. [Educational Codeforces Round 81 (Rated for Div. 2)]E. Permutation Separation(线段树,思维,前缀和)

    [Educational Codeforces Round 81 (Rated for Div. 2)]E. Permutation Separation(线段树,思维,前缀和) E. Permuta ...

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

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

  5. Educational Codeforces Round 43 (Rated for Div. 2)

    Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...

  6. Educational Codeforces Round 35 (Rated for Div. 2)

    Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...

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

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

  9. Educational Codeforces Round 63 (Rated for Div. 2) 题解

    Educational Codeforces Round 63 (Rated for Div. 2)题解 题目链接 A. Reverse a Substring 给出一个字符串,现在可以对这个字符串进 ...

随机推荐

  1. gtk编译之makefile的写法(之一)

    在学习c语言GUI编程时想必大家都会遇见这样一个问题买就是每次编译都要敲`pkg-config --cflags --libs gtk+-2.0`这个烦恼吧 这是我们可以编写一个makefile文件这 ...

  2. INTERSPEECH2020 语音情感分析论文之我见

    摘要:本文为大家带来InterSpeech2020 语音情感分析25篇论文中的其中8篇的总结. 本文分享自华为云社区<INTERSPEECH2020 语音情感分析论文总结一>,原文作者:T ...

  3. centos 7升级gcc到10.2.0

    安装gcc 由于 Linux 操作系统的自由.开源,在其基础上衍生出了很多不同的 Linux 操作系统,如 CentOS.Ubuntu.Debian 等.这些 Linux 发行版中,大多数都默认装有 ...

  4. OO_Unit2 关于性能优化与测试的那些事

    OO_Unit2 关于性能优化与测试的那些事 OO的第2单元到本周也就正式完结了.尽管这个单元的主旋律是多线程,但"面向对象"的基本思想仍然是我们一切架构与优化的出发点与前提.因此 ...

  5. Java集合--Java核心面试知识整理(二)

    目前CSDN,博客园,简书同步发表中,更多精彩欢迎访问我的gitee pages 目录 JAVA集合 2.1 接口继承关系和实现 2.2 List 2.2.1 ArrayList(数组) 2.2.2 ...

  6. 记一次xss漏洞挖掘

    博客园在整改中,无法更新文章,难受啊... 记录一次react的xss漏洞发现,比较有意思: 某个站: 直接输入<xxx>,直接把我跳转到了404,猜测可能做了一些验证: 尝试多重编码,发 ...

  7. 谈谈SSRF漏洞挖掘

    最近看了很多ssrf漏洞挖掘技巧和自己以往挖掘ssrf漏洞的一些技巧和经验,简单的总结下: 之前自己总结的: ssrf=服务器端请求伪造 基于服务器攻击 url链接 -->内网漫游/内网服务探测 ...

  8. 案例分析——Who is the king of handwriting notes?

    案例分析--Who is the king of handwriting notes? 项目 内容 这个作业属于那个课程 2021春季学期软件工程(罗杰.任健) 这个作业的要求在哪里 案例分析 我在这 ...

  9. 1026 Table Tennis

    A table tennis club has N tables available to the public. The tables are numbered from 1 to N. For a ...

  10. jmeter响应时间与postman响应时间为什么不一样?

    postman响应时间 是一个线程或者一个用户再者说是发送一次请求的响应时间,一般都是200ms一下: 而jmeter属于并行,就是多个用户去访问这个功能点或者接口,多个用户同时访问,就会造成压力,自 ...