A
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
#ifndef ONLINE_JUDGE
freopen("test.in","r",stdin);
#endif
int T;
cin>>T;
while(T--) {
int x,k;
cin>>x>>k;
if(x%k==0) {
cout<<"2"<<al<<x-1<<" "<<1<<al;
}
else {
cout<<"1"<<al<<x<<al;
}
}
return 0;
}
B
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
#ifndef ONLINE_JUDGE
freopen("test.in","r",stdin);
#endif
int T;
cin>>T;
while(T--) {
int n;
cin>>n;
string buff;
cin>>buff;
int i,a=0,b=0,wwx=0;
fz0k(i,n) {
if(buff[i]=='<') {
a++;
b=0;
}
else {
b++;
a=0;
}
wwx=max(wwx,max(a,b));
}
cout<<wwx+1<<" \n"[T>0];
}
return 0;
}
C
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
#ifndef ONLINE_JUDGE
freopen("test.in","r",stdin);
#endif
int T;
cin>>T;
while(T--) {
string buff;
cin>>buff;
int n=(int)buff.size();
int i;
char opt='1';
string wwx="";
fd0k(i,n) {
if(buff[i]!='?') {
opt=(buff[i]=='0')?'0':'1';
}
wwx=opt+wwx;
}
cout<<wwx<<al;
}
return 0;
}
D
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
#ifndef ONLINE_JUDGE
freopen("test.in","r",stdin);
#endif
int T;
cin>>T;
while(T--) {
int n;
cin>>n;
string buff;
cin>>buff;
int i,a=0,b=0;
fz0k(i,n) {
if(buff[i]=='(') {
a++;
}
}
if(n&1||a!=n/2) {
cout<<"-1"<<al;
continue;
}
auto judge=[&](char mark) {
int oo=0;
fz0k(i,n) {
if(buff[i]==mark) {
oo++;
}
else {
oo--;
}
if(oo<0) {
return false;
}
}
return true;
};
a=0;
b=0;
if(judge('(')||judge(')')) {
cout<<1<<al;
fz0k(i,n) {
cout<<1<<" \n"[i==n-1];
}
continue;
}
cout<<2<<al;
int opt=0;
fz0k(i,n) {
if(buff[i]=='(') {
a++;
}
else {
b++;
}
if(a>b) {
cout<<(opt=1)<<' ';
}
else if(a<b) {
cout<<(opt=2)<<' ';
}
else {
cout<<opt<<' ';
}
}
cout<<endl;
}
return 0;
}