PROBLEMSSUBMIT CODEMY SUBMISSIONSSTATUSHACKSROOMSTANDINGSCUSTOM INVOCATION
B. Kuroni and Simple Strings
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
Now that Kuroni has reached 10 years old, he is a big boy and doesn’t like arrays of integers as presents anymore. This year he wants a Bracket sequence as a Birthday present. More specifically, he wants a bracket sequence so complex that no matter how hard he tries, he will not be able to remove a simple subsequence!

We say that a string formed by n characters ‘(’ or ‘)’ is simple if its length n is even and positive, its first n2 characters are ‘(’, and its last n2 characters are ‘)’. For example, the strings () and (()) are simple, while the strings )( and ()() are not simple.

Kuroni will be given a string formed by characters ‘(’ and ‘)’ (the given string is not necessarily simple). An operation consists of choosing a subsequence of the characters of the string that forms a simple string and removing all the characters of this subsequence from the string. Note that this subsequence doesn’t have to be continuous. For example, he can apply the operation to the string ‘)()(()))’, to choose a subsequence of bold characters, as it forms a simple string ‘(())’, delete these bold characters from the string and to get ‘))()’.

Kuroni has to perform the minimum possible number of operations on the string, in such a way that no more operations can be performed on the remaining string. The resulting string does not have to be empty.

Since the given string is too large, Kuroni is unable to figure out how to minimize the number of operations. Can you help him do it instead?

A sequence of characters a is a subsequence of a string b if a can be obtained from b by deletion of several (possibly, zero or all) characters.

Input
The only line of input contains a string s (1≤|s|≤1000) formed by characters ‘(’ and ‘)’, where |s| is the length of s.

Output
In the first line, print an integer k — the minimum number of operations you have to apply. Then, print 2k lines describing the operations in the following format:

For each operation, print a line containing an integer m — the number of characters in the subsequence you will remove.

Then, print a line containing m integers 1≤a1<a2<⋯<am — the indices of the characters you will remove. All integers must be less than or equal to the length of the current string, and the corresponding subsequence must form a simple string.

If there are multiple valid sequences of operations with the smallest k, you may print any of them.

Examples
inputCopy
(()((
outputCopy
1
2
1 3
inputCopy
)(
outputCopy
0
inputCopy
(()())
outputCopy
1
4
1 2 5 6
Note
In the first sample, the string is ‘(()((’. The operation described corresponds to deleting the bolded subsequence. The resulting string is ‘(((’, and no more operations can be performed on it. Another valid answer is choosing indices 2 and 3, which results in the same final string.

In the second sample, it is already impossible to perform any operations.

题意:给了一个字符串,然后让你取一个题中定义的简单序列,问你最少要取多少次 才能让剩余的字符串取不了简单序列

思路
我们把左括号 和右括号分别用数组存起来
这样的话 我们这样贪心取 我左括号取一个位置最靠左的
那么 右括号就取一个位置最靠右的 知道其中一个数组没有可以取的了 或者左边的位置>右边的位置了
其实想一下 答案只有0或者1

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define me(a,x) memset(a,x,sizeof a)
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define all(x) (x).begin(), (x).end()
#define pb(a) push_back(a)
#define paii pair<int,int>
#define pali pair<ll,int>
#define pail pair<int,ll>
#define pall pair<ll,ll>
#define fi first
#define se second
char s[1005];
vector<int>c,d;
int main()
{
    cin>>s+1;
    int len=strlen(s+1);
    int num=0;
    for(int i=1; i<=len; i++)
    {
        if(s[i]=='(') c.pb(i);
        else d.pb(i);
    }
   int l=0,r=d.size()-1;
   while(l<c.size() &&r>=0&&c[l]<d[r]){
      l++;
      r--;
      num=1;
   }
   if(!num) puts("0");
   else
   {
       puts("1");
       cout<<l+d.size()-r-1<<endl;
       for(int i=0;i<l;i++) cout<<c[i]<<" ";
       for(int i=r+1;i<d.size();i++) cout<<d[i]<<" ";
   }

    return 0;
}