5 solutions

  • 0
    @ 2024-12-20 19:55:50

    最低代码

    #include<bits/stdc++.h>
    using namespace std;
    int main(){
    	int sum=0;
    	string ppp;
    	cin>>ppp;
    	for(int i=0;i<ppp.size();i++){
    		if(ppp[i]=='(')sum++;
    		else if(ppp[i]==')'){
    			if(sum>0)sum--;
    			else{
    				cout<<"NO";
    				return 0;
    			}
    		}
    	}if(sum)cout<<"NO";
    	else cout<<"YES";
    	return 0;
    }
    
    • -2
      @ 2023-12-12 19:08:26
      #include <bits/stdc++.h>
      using namespace std;
      int f;
      int main(int argc, char **argv){
      	char c;
      	while((c = getchar()) != '@'){
      		if (c == '('){
      			f++;
      		}
      		if (c == ')'){
      			f--;
      		}
      		if (f < 0){
      			printf("NO");
      			return 0;
      		}
      	}
      	if (f == 0){
      		printf("YES");
      	}else{
      		printf("NO");
      	}
      	return 0;
      }
      
      • -4
        @ 2023-12-13 13:54:34

        #include <bits/stdc++.h> using namespace std; string a; int top=-1; void push(char b){ top++; a[top]=b; } void pop(){ a[top]=0; top--;

        } bool empty() { return top==-1; } int main(){ cin>>a; for(int i=0;i<a.size();i++){ if(a[i]'('){ push(a[i]); } if(a[i]')'){ if(empty()){ cout<<"NO"; return 0; } else{ pop(); } } } if(empty()){ cout<<"YES"; } else{ cout<<"NO"; } }

        • -4
          @ 2023-12-12 13:12:17
          #include<iostream>
          using namespace std;
          void YESorNO(bool a,string yes="YES",string no="NO"){//输出
          	if(a)
          	cout<<yes;
          	else
          	cout<<no;
          }
          int main(){
          	string a;
          	cin>>a;
          	int z=0,y=0;
          	for(int i=0;i<a.size();i++)//循环
          	if(a[i]=='(')
          	z++;
          	else
          	if(a[i]==')')
          	y++;
          	YESorNO(z==y);
          } 
          
          • @ 2023-12-12 13:13:00

            这一题,就无聊。

            本来想着先玩玩看看能骗到多少分,没想到过了……

        • -4
          @ 2023-12-7 20:14:18

          so easy!!!❤️

          #include<bits/stdc++.h>
          using namespace std;
          int main(){
              stack<char> a;
              char n;
              while(cin>>n){
                  if(n==')' && a.size()==0){
                      cout<<"NO";
                      return 0;
                  }
                  if(n=='(') a.push(n);
                  if(n==')'){
                      if(a.top()=='(') a.pop();
                      else{
                          cout<<"NO";
                          return 0;
                      }
                  }
              }
              if(a.size()!=0) cout<<"NO";
              else cout<<"YES";
              return 0;
          }
          
          • 1

          Information

          ID
          838
          Time
          1000ms
          Memory
          256MiB
          Difficulty
          6
          Tags
          # Submissions
          98
          Accepted
          33
          Uploaded By