被低年级大佬暴踩的一次比赛 AK失败获得#3

T1 括号

题目大意:

对于任意 i 位置若与 n-i+1 相反则输出YES 否则输出NO

思路:

暴力判断即可

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 #include<cstdlib>
 5 #include<cmath>
 6 #include<algorithm>
 7 #include<queue>
 8 #include<vector>
 9 #include<map>
10 #define inf 2139062143
11 #define ll long long
12 #define MAXN 100100
13 using namespace std;
14 inline int read()
15 {
16     int x=0,f=1;char ch=getchar();
17     while(!isdigit(ch)) {if(ch=='-')f=-1;ch=getchar();}
18     while(isdigit(ch)) {x=x*10+ch-'0';ch=getchar();}
19     return x*f;
20 }
21 char s[200];
22 int n,a[200];
23 inline int work()
24 {
25     for(int i=1;i<=n;i++)
26         if((a[i]^a[n-i+1])==0) return 0;
27     return 1;
28 }
29 int main()
30 {
31     freopen("brackets.in","r",stdin);
32     freopen("brackets.out","w",stdout);
33     int T=read();
34     while(T--)
35     {
36         scanf("%s",s+1);n=strlen(s+1);
37         for(int i=1;i<=n;i++)
38             if(s[i]=='(') a[i]=1;
39             else a[i]=0;
40         puts(work()?"Yes":"No");
41     }
42 }
View Code

相关文章:

  • 2021-07-21
  • 2022-12-23
  • 2021-10-08
  • 2021-08-09
  • 2020-11-04
  • 2018-10-28
  • 2021-08-08
猜你喜欢
  • 2022-12-23
  • 2021-07-16
  • 2022-12-23
  • 2022-12-23
  • 2021-12-15
  • 2021-12-25
相关资源
相似解决方案