10 solutions

  • 0
    @ 2022-1-2 22:45:44

    我是蒟蒻,不会写题解,所以。。。

    #include<bits/stdc++.h>
    using namespace std;
    char arr[107];
    char brr[107];
    stack<int> s;
    int main()
    {
    	while(cin>>arr)
    	{
    		int l=strlen(arr);
    		for(int i=0;i<l;i++)
    		{
    			if(arr[i]=='(')
    			{
    			    s.push(i);
    				brr[i]=' ';
    			}
    			else if(arr[i]==')')
    			{
    				if(!s.empty())
    				{
    					s.pop();
    					brr[i]=' ';
    				}
    				else
    				{
    					brr[i]='?';
    				}
    			}
    			else
    			{
    				brr[i]=' ';
    			}
    		}
    		while(!s.empty())
    		{
    			brr[s.top()]='$';
    			s.pop();
    		}
    		cout<<arr<<endl;
    		cout<<brr<<endl;
    		memset(brr,0,sizeof(brr));
    		memset(arr,0,sizeof(arr));
    	}
    	return 0;
    }
    

    Information

    ID
    292
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    6
    Tags
    # Submissions
    193
    Accepted
    56
    Uploaded By