/ Randle /

记录详情

Accepted

/in/foo.cc: In function 'int main()':
/in/foo.cc:5:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define rep(i,j,k) for (int i=j;i<=k;i++)
                                   
/in/foo.cc:15:9:
     rep(i,1,strlen(s+1)){
         ~~~~~~~~~~~~~~~           
/in/foo.cc:15:5: note: in expansion of macro 'rep'
     rep(i,1,strlen(s+1)){
     ^~~
# 状态 耗时 内存占用
#1 Accepted 1ms 224.0 KiB
#2 Accepted 1ms 228.0 KiB
#3 Accepted 1ms 224.0 KiB
#4 Accepted 1ms 228.0 KiB
#5 Accepted 1ms 224.0 KiB
#6 Accepted 1ms 228.0 KiB
#7 Accepted 259ms 404.0 KiB
#8 Accepted 259ms 404.0 KiB
#9 Accepted 260ms 404.0 KiB
#10 Accepted 260ms 404.0 KiB

代码

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,j,k) for (int i=j;i<=k;i++)
#define dep(i,j,k) for (int i=j;i>=k;i--)
#define M(a,b) memset(a,b,sizeof(a))
using namespace std;
char s[100005];
int cntl,cntr,ans;
int main(){
//	freopen("bracket.in","r",stdin);
//	freopen("bracket.out","w",stdout);
    scanf("%s",s+1);
    rep(i,1,strlen(s+1)){
        if (s[i] == '(') cntl++;
        else if (s[i]==')' && cntl) cntl--;
             else cntr++;
    }
    ans=cntl/2+(cntl%2)+cntr/2+(cntr%2);
    printf("%d\n",ans);
    return 0;
}

信息

递交者
类型
递交
题目
括号序列 T1
题目数据
下载
语言
C++
递交时间
2019-11-09 18:44:50
评测时间
2019-11-09 18:44:50
评测机
分数
100
总耗时
1048ms
峰值内存
404.0 KiB