QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#657536#9463. 基础 ABC 练习题wrkwrk40 1ms3896kbC++207.1kb2024-10-19 14:57:022024-10-19 14:57:02

Judging History

你现在查看的是最新测评结果

  • [2024-10-19 14:57:02]
  • 评测
  • 测评结果:40
  • 用时:1ms
  • 内存:3896kb
  • [2024-10-19 14:57:02]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
bool st;
namespace _wrk{;
template<int mod>
struct modint{
	int num;
	const static __uint128_t brt=((__uint128_t)(1)<<(64))/mod;
	modint(){
		num=0;
	}
	modint(int x){
		num=x%mod;
	}
	modint(long long x){
		num=x%mod;
	}
	modint<mod>operator=(int x){
		num=x%mod;
		return (*this);
	}
	modint<mod>operator=(long long x){
		num=x%mod;
		return (*this);
	}
	modint<mod>operator=(modint<mod>x){
		num=x.num;
		return (*this);
	}
	modint<mod> operator+(modint<mod> c)const{
		long long x=num+c.num;
		return x>=mod?x-mod:x;
	}
	modint<mod> operator-(modint<mod> c)const{
		long long x=num-c.num;
		return x<0?x+mod:x;
	}
	modint<mod>operator*(modint<mod>c)const{
		long long x=(long long)num*c.num;
		x=x-mod*(brt*x>>64);
		while(x>=mod)x-=mod;
		return x;
	}
	modint<mod>fpof(long long x)const{
		if(x<0)return inv().fpof(-x);
		if(x==0)return 1;
		auto c=((*this)*(*this)).fpof(x/2);
		if(x&1)return c*(*this);
		else return c;
	}
	struct modint_pow{
		int pf;
		modint_pow(int x){
			pf=x;
		}
		modint_pow(modint<mod> x){
			pf=x.num;
		}
		modint_pow operator+(modint_pow x){
			return pf+x.pf;
		}
	};
	modint_pow operator*(){
		return modint_pow(num);
	}
	modint<mod> operator*(modint_pow x){
		return (*this).fpof(x.pf);
	}
	modint<mod>inv()const{
		return fpof(mod-2);
	}
	modint<mod>operator/(modint<mod>c){
		return (*this)*c.inv();
	}
	operator int(){
		return num;
	}

	modint<mod>operator+=(modint<mod> c){
		return (*this)=(*this)+c;
	}
	modint<mod>operator-=(modint<mod> c){
		return (*this)=(*this)-c;
	}
	modint<mod>operator*=(modint<mod> c){
		return (*this)=(*this)*c;
	}
	modint<mod>operator/=(modint<mod> c){
		return (*this)=(*this)/c;
	}
	modint<mod>operator-(){
		return mod-num;
	}
	friend ostream& operator<<(ostream &w,modint<mod>&&x){
		w<<x.num;
		return w;
	}
	friend istream& operator>>(istream &w,modint<mod>&x){
		w>>x.num;
		x.num%=mod;
		return w;

	}
	bool operator==(modint<mod>x){
		return num==x.num;
	}

};

template<int mod,class type>
modint<mod>operator+(type a,modint<mod>b){
	return modint<mod>(a)+b;
}
template<int mod,class type>
modint<mod>operator-(type a,modint<mod>b){
	return modint<mod>(a)-b;
}
template<int mod,class type>
modint<mod>operator*(type a,modint<mod>b){
	return modint<mod>(a)*b;
}
template<int mod,class type>
modint<mod>operator/(type a,modint<mod>b){
	return modint<mod>(a)/b;
}
#define int long long

template<class type,int N>
struct matrix{
	type a[N+2][N+2];
	int n;
	type* operator[](int pos){
		return a[pos];
	}
	matrix<type,N> operator*(matrix<type,N>b){
		matrix<type,N>ans;
		ans.n=n;
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				for(int k=1;k<=n;k++){
					ans[i][j]+=a[i][k]*b[k][j];
				}
			}
		}
		return ans;
	}
};
template<class type>
type fp(type a,int b){
	if(b==0)return type();
	if(b==1)return a;
	type w=fp(a*a,b/2);
	if(b%2)return w*a;
	return w;
}
template<class type,int N>
struct backup_array{
	type name[N+5];
	vector<vector<pair<int,int>>>cc;
	void new_array(){
		cc.push_back(vector<pair<int,int>>());
	}
	backup_array(){
		cc.resize(1);
	}
	struct x{
		int id;
		type* name;
		vector<vector<pair<int,int>>> &cc;
		operator type(){
			return name[id];
		}
		type operator=(type w){
			cc.back().push_back({id,name[id]});
			name[id]=w;
			return w;
		}
	};
	x operator[](int pos){
		return {pos,name,cc};
	}
	void backup(){
		reverse(cc.back().begin(),cc.back().end());
		for(auto &x:cc.back()){
			name[x.first]=x.second;
		}
		cc.pop_back();
	}
};
template<class type,int N>
struct Math{
	type jc[N+5],inv[N+5],invjc[N+5];
	Math(){
		jc[0]=jc[1]=inv[1]=invjc[1]=invjc[0]=1;
		for(int i=2;i<=N;i++){
			jc[i]=jc[i-1]*type(i);
		}
		invjc[N]=type(1)/jc[N];
		for(int i=N-1;i>=2;i--){
			invjc[i]=invjc[i+1]*type(i+1);
		}
		for(int i=1;i<=N;i++){
			inv[i]=invjc[i]*jc[i-1];
		}
	}
	type binom(int a,int b){
		return jc[a]*invjc[b]*invjc[a-b];
	}
	type catalan(int n){
		return binom(2*n,n)/type(n+1);
	}
};
template<class type,int num,int maxnum>
struct pows{
	type w[maxnum+5];
	pows(){
		w[0]=type(1);
		for(int i=1;i<=maxnum;i++)w[i]=w[i-1]*type(num);
	}
	type operator[](int pos){
		return w[pos];
	}
};
#ifdef use_seg_tree
template<class type,class laz_type,int len>
struct segment_tree{
	type a[len<<2];
	laz_type laz[len<<2];
	void pushup(int now){
		PUSHUP_VALUE
	}
	void pushdown(int now,int l,int r){
		PUSHDOWN_VALUE
	}
	void build(int now,int l,int r){
		if(l+1==r){
			FIRST_VALUE
			return;
		}
		LAZ_CLEAR
		int mid=(l+r)>>1;
		build(now<<1,l,mid);
		build(now<<1|1,mid,r);
		pushup(now);
	}
	void do1(int now,int l,int r,int L,int R,...){
		if(l+1!=r)pushdown(now,l,r);
		if(R<=l||r<=L)return;
		if(L<=l&&r<=R){
			FULL_BLOCK_VALUE
			return;
		}
		int mid=(l+r)>>1;
		do1(now<<1,l,mid,L,R,...);
		do1(now<<1|1,mid,r,L,R,...);
		pushup(now);
	}
	void do1_one(int now,int l,int r,int p,...){
		if(l+1!=r)pushdown(now,l,r);
		if(l+1==r){
			DO1_VALUE
			return;
		}
		int mid=(l+r)>>1;
		if(p<mid)do1_one(now<<1,l,mid,p,...);
		else do1_one(now<<1|1,mid,r,p,...);
		pushup(now);
	}
	type qu1(int now,int l,int r,int L,int R){
		if(l+1!=r)pushdown(now,l,r);
		if(R<=l||r<=L)return BASE_VALUE
		if(L<=l&&r<=R)return a[now];
		int mid=(l+r)>>1;
		return RETURN_VALVE qu1(now<<1,l,mid,L,R)+qu1(now<<1|1,mid,r,L,R);
	}
	type qu1_one(int now,int l,int r,int p){
		if(l+1!=r)pushdown(now,l,r);
		if(l+1==r)return a[now];
		int mid=(l+r)>>1;
		if(p<mid)return qu1_one(now<<1,l,mid,p);
		else return qu1_one(now<<1|1,mid,r,p);

	}
};
#endif
//#define mod 998244353
//#define mint modint<mod>
//pows<mint,2,1000006>tp;
//Math<mint,1000006>math;
//vector<int>g[1000006]
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
//	freopen("b.in","r",stdin);
	int t,c;
	cin>>t>>c;
	while(t--){
		
		int n;
		cin>>n;
		string s;
		cin>>s;
		string t;
		cin>>t;
		string p;
		cin>>p;
		p='#'+p;
		if(n!=60){
			cout<<"-1\n";
			continue;
		}
		int ans=0;
		for(int i=0;i<=n;i++){
			for(int j=0;i+j<=n;j++){
				if(s[i]=='1'&&t[j]=='1'){
					int res=1;
					int k=n-i-j;
//					i ABC
//					j BCA
//					k CAB
					int na=0,nb=0,nc=0;
					for(int f=1;f<=3*n;f++){
						if(p[f]=='A'){
							if(!((na<i)||(i<=na&&na<i+k&&nc>=na+1-i)||(na>=i+k&&nc>=na+1-i))){
								res=0;
							}
//							cout<<na<<' '<<nc<<'\n'; 
								na++;
						} 
						if(p[f]=='B'){
							if(!((nb<j)||(j<=nb&&nb<j+i&&na>=nb+1-j)||(nb>=j+i&&na>=nb+1-j))){
								res=0;
							}
								nb++;
						} 
						if(p[f]=='C'){
							if(!((nc<k)||(k<=nc&&nc<k+j&&nb>=nc+1-k)||(nc>=k+j&&nb>=nc+1-k))){
								res=0;
							}
							nc++;
						} 
					}
					ans=max(ans,res);
//					if(res==1){
//						cout<<i<<' '<<j<<' '<<k<<'\n';
//					}
				}
			}
		}
		cout<<ans<<'\n';
	}

	return 0;
}
}
bool en;
signed main(){
	#ifdef LOCAL_WRK
	cerr<<"[Static Memory : "<<fixed<<((&st)-(&en))/1048576.0<<"MB]"<<endl;
	#endif
	   return _wrk::main();
}





详细

Subtask #1:

score: 20
Accepted

Test #1:

score: 20
Accepted
time: 1ms
memory: 3588kb

input:

60 1
1
11
11
ABC
2
111
111
CABABC
3
1111
1111
CAABBCBAC
4
11111
11111
BACBBACBACAC
5
111111
111111
CABCCBBAABCCBAA
6
1111111
1111111
ABABABCACBCBCCACBA
7
11111111
11111111
BCAABACBBCBBABCCAACAC
8
111111111
111111111
CCBCBBBCAABCBCAAAAACBCBA
9
1111111111
1111111111
CCCCACABCBABAABCCAABABBCBBA
10
1111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1

result:

ok Accepted!!!

Test #2:

score: 20
Accepted
time: 0ms
memory: 3536kb

input:

60 1
1
11
11
CBA
2
111
111
BACACB
3
1111
1111
BCBCACABA
4
11111
11111
CCBACABBBCAA
5
111111
111111
BCACBBABBCCAACA
6
1111111
1111111
BBCBACCAACBCBCAABA
7
11111111
11111111
ACBCCBBAABAABCACCACBB
8
111111111
111111111
BAACACBACCCBAACCBABABBCB
9
1111111111
1111111111
BABCBCAAAAABBCCCACBCBBABACC
10
1111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1

result:

ok Accepted!!!

Test #3:

score: 20
Accepted
time: 0ms
memory: 3580kb

input:

60 1
1
11
11
BCA
2
111
111
BCABCA
3
1111
1111
CBACCAABB
4
11111
11111
BACBCBBCCAAA
5
111111
111111
BCCCBABACCBABAA
6
1111111
1111111
ACAACBABABBCACBCCB
7
11111111
11111111
BBBCABCCCAABCACBACAAB
8
111111111
111111111
ACCACAABACBAABBCBCBBACBC
9
1111111111
1111111111
BCCBACBBACCCBCCAABAACABAABB
10
1111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1

result:

ok Accepted!!!

Test #4:

score: 20
Accepted
time: 1ms
memory: 3872kb

input:

60 1
1
11
11
BCA
2
111
111
ACABCB
3
1111
1111
BABCABCCA
4
11111
11111
CCABACABBACB
5
111111
111111
ABBBCBBCACCAACA
6
1111111
1111111
CACBABCABCCBABAACB
7
11111111
11111111
BACBCABACBBCCCBAAACAB
8
111111111
111111111
CABABBCAACABCBACBABACBCC
9
1111111111
1111111111
BCBAACBABABCBACBABABCCACACC
10
1111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1

result:

ok Accepted!!!

Test #5:

score: 20
Accepted
time: 1ms
memory: 3876kb

input:

60 1
1
11
11
ABC
2
111
111
BBCACA
3
1111
1111
ACBBCBAAC
4
11111
11111
ABACACCCABBB
5
111111
111111
ACCCCCAAABABBBB
6
1111111
1111111
ABAABBBBCCCCCCAABA
7
11111111
11111111
ACBBBACCCCCCAABABBBAA
8
111111111
111111111
CAAABAAACCCCBBCBBBCACBAB
9
1111111111
1111111111
ABAAACBBCCCCCCCBAAABAACBBBB
10
1111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
0

result:

ok Accepted!!!

Test #6:

score: 20
Accepted
time: 1ms
memory: 3848kb

input:

60 1
1
11
11
BCA
2
111
111
ACCBAB
3
1111
1111
BACCACBBA
4
11111
11111
AAABBCBCBACC
5
111111
111111
AABBBBCCBCCAACA
6
1111111
1111111
AAACCBCCCAABACBBBB
7
11111111
11111111
AAACACCACBBAABBCBCCBB
8
111111111
111111111
AAACAAABBBBBBBCBACCCACCC
9
1111111111
1111111111
BBCCACCCACCACCBAABBAAAABBBB
10
1111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1

result:

ok Accepted!!!

Test #7:

score: 20
Accepted
time: 1ms
memory: 3640kb

input:

60 1
1
11
11
BCA
2
111
111
ACCABB
3
1111
1111
CAABBBCAC
4
11111
11111
BBCCBCCABAAA
5
111111
111111
BAABBBCCCCCAABA
6
1111111
1111111
AACACCCCBABBBCAABB
7
11111111
11111111
AACBBCBBBCCCCCAAABBAA
8
111111111
111111111
AAAABBCBBBBCBBCCCCCCAAAA
9
1111111111
1111111111
ABBBBBBBBCCBCAACCACAACCAAAC
10
1111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1

result:

ok Accepted!!!

Test #8:

score: 20
Accepted
time: 1ms
memory: 3876kb

input:

60 1
1
11
11
ABC
2
111
111
AABCBC
3
1111
1111
ABAACBBCC
4
11111
11111
AABCCBBBCACA
5
111111
111111
AAACCABBBACBCCB
6
1111111
1111111
AABBBBBBCCACAACACC
7
11111111
11111111
AAAABBBBBBCCACCCCCBAA
8
111111111
111111111
ACCBABBABBBBBCCCACCCAAAA
9
1111111111
1111111111
BAAAABCCCCCCCBBAABAACABCBBB
10
1111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
0

result:

ok Accepted!!!

Test #9:

score: 20
Accepted
time: 1ms
memory: 3580kb

input:

60 1
1
11
11
CAB
2
111
111
CCAABB
3
1111
1111
ACCCABBAB
4
11111
11111
AAABBBBCCACC
5
111111
111111
BCACCCCBAAAABBB
6
1111111
1111111
CAAACABABACCCBCBBB
7
11111111
11111111
ACAAACBCCCCBCAABBABBB
8
111111111
111111111
ACCAACACCCCCABABAABBBBBB
9
1111111111
1111111111
AACAAAAAACBCCBCBACBBBBBBCCC
10
1111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1

result:

ok Accepted!!!

Test #10:

score: 20
Accepted
time: 0ms
memory: 3532kb

input:

60 1
1
11
11
BCA
2
111
111
ACACBB
3
1111
1111
AABCCCABB
4
11111
11111
CBCCCABABABA
5
111111
111111
ACACCCAABBCBABB
6
1111111
1111111
BACAAAACCBABCBCBCB
7
11111111
11111111
AAAAABBBBCCBBCCCCACAB
8
111111111
111111111
AACCCCCCABAAACAABCBBBBBB
9
1111111111
1111111111
AABAAAABCCCCABCCCABBCCABBBB
10
1111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1

result:

ok Accepted!!!

Test #11:

score: 20
Accepted
time: 1ms
memory: 3580kb

input:

60 1
1
11
11
BCA
2
111
111
CBBCAA
3
1111
1111
AABABCCCB
4
11111
11111
BABCBBCAAACC
5
111111
111111
AAACBBBBBCAACCC
6
1111111
1111111
BBBBBCCCCCCAABAAAA
7
11111111
11111111
BAAAABAACCCABBCCBBBCC
8
111111111
111111111
ABABBBBBCBCCCACCCCAAABAA
9
1111111111
1111111111
AAAABBAABCABACCCACCCBBCBCBB
10
1111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1

result:

ok Accepted!!!

Subtask #2:

score: 20
Accepted

Dependency #1:

100%
Accepted

Test #12:

score: 20
Accepted
time: 1ms
memory: 3880kb

input:

60 2
1
01
11
ABC
2
101
001
ACBABC
3
0011
1000
AAACBBCBC
4
11100
00100
BACABCABACBC
5
001101
110010
ACBABCCABBCCAAB
6
0101010
1000011
CABBAAACACBBCCABCB
7
10010111
10100111
CABAAACBBAACBCACBBBCC
8
100101000
100000110
BACBCACBBAABCCCABCBAACBA
9
1100010100
0111110011
CAABCBBABCACBCACABCABAACBBC
10
0001...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1

result:

ok Accepted!!!

Test #13:

score: 20
Accepted
time: 1ms
memory: 3644kb

input:

60 2
1
01
01
CAB
2
011
101
ABCCBA
3
1111
0000
CBBAACCBA
4
00011
10011
BCCBCCABABAA
5
011111
111011
ACBBABCBCCAACBA
6
1011101
1101000
CBABBCACBAABABCACC
7
00001111
11010100
BCACAABCBBBCCABABCACA
8
110110100
010010100
ABAABCABCABAACCCCBBBBCCA
9
0000111111
1011100011
BAAABBCCABBBBCABACBACACCACC
10
0011...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1

result:

ok Accepted!!!

Test #14:

score: 20
Accepted
time: 0ms
memory: 3584kb

input:

60 2
1
01
00
ABC
2
111
000
CAABBC
3
0101
0011
CAACBCBAB
4
11011
01001
CABBCAACBBCA
5
000010
010100
BCCCACAAACBBBBA
6
0011011
0011000
BCACCBAAAAABCBCBBC
7
11000001
11111111
AACBCABACCBBCABCCBAAB
8
111010100
111101010
CBABCACBABAACBABCCCBCAAB
9
1001111111
1011000111
CAABCACCABBBABBCACCABBCAACB
10
0011...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1

result:

ok Accepted!!!

Test #15:

score: 20
Accepted
time: 1ms
memory: 3528kb

input:

60 2
1
00
10
BCA
2
110
000
BCAABC
3
0111
1001
CACAABBBC
4
10101
00000
ACCBCAABBACB
5
010001
100001
BBCBBAACCBACACA
6
0100101
0100010
CCAAAABCCAABBCBBBC
7
10010000
10010011
BCBCACBCBAAAABCABBCCA
8
001101111
110010111
CABACABCACBBABCBCABACABC
9
1000111100
1011101001
ACBCABABBCCBABCCAAACBBBACAC
10
1111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1

result:

ok Accepted!!!

Test #16:

score: 20
Accepted
time: 0ms
memory: 3656kb

input:

60 2
1
10
11
CAB
2
110
100
AABBCC
3
0100
0110
CAABCBABC
4
01010
01000
BCBCABACBCAA
5
001110
100000
AAABBCCCABCBABC
6
1000000
1101100
ACCBACBCAABCAABBCB
7
11011110
01000000
AAAAABABBBCBBBACCCCCC
8
101000000
010000000
ACBABBCCCCCCCABAAABAABBB
9
1000000000
1000000000
CCCCCCCCCAABAAABABBBABBAABB
10
0111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1

result:

ok Accepted!!!

Test #17:

score: 20
Accepted
time: 1ms
memory: 3576kb

input:

60 2
1
01
10
ABC
2
100
100
BCABCA
3
1000
1100
CABACCBAB
4
11001
10000
AABCBACABBCC
5
110000
101110
BACBCAABCABCBCA
6
1110000
1111100
AABBBBCABCCCCABAAC
7
10110000
11100000
AAACCABBCAABCBBABBCCC
8
001111100
011000000
ABAACAAAACABCBCBBBBBCCCC
9
0110000000
1111000000
AACBBACBBBCBCABACACBCAABCCA
10
1111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
0

result:

ok Accepted!!!

Test #18:

score: 20
Accepted
time: 0ms
memory: 3620kb

input:

60 2
1
10
11
ABC
2
100
100
CABCAB
3
1000
1000
CCABCABAB
4
11100
10000
ACACBABCABCB
5
111101
100000
AABCABCBACABBCC
6
1000000
0100000
BCACCCCCABAAABBBBA
7
10101110
11000000
AAABBCBBCACCCABBAACBC
8
111110000
001100000
ACBBCBBCABACCACBBABAACCA
9
1110000000
1111110000
CAAACBCCBBAAABCCBACABACCBBB
10
1100...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1

result:

ok Accepted!!!

Test #19:

score: 20
Accepted
time: 0ms
memory: 3896kb

input:

60 2
1
11
10
ABC
2
100
110
BCABCA
3
1000
1111
BBCBACCAA
4
10000
10011
BCABCABCABCA
5
011111
100000
AABCBCABACABCBC
6
1110000
1000000
CAAACCCBBBCAACABBB
7
10000000
01000000
ABBCACCCABBACABACBBAC
8
110100011
100000000
AABBCABCCAABBCABCABCABCC
9
1111011100
1100000000
AAACABBBBBCACABCCBABCACBCCA
10
0111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1

result:

ok Accepted!!!

Test #20:

score: 20
Accepted
time: 1ms
memory: 3528kb

input:

60 2
1
10
10
CAB
2
110
100
ABCACB
3
1000
1000
CABCABCAB
4
10111
10000
CABCABCABCAB
5
100000
110000
BCCAABCBCABACAB
6
1000000
1111000
CCCABACAABBCABCABB
7
10000000
11000110
BBCBBBCCACCCBABAAACAA
8
110000000
100000000
AACBCABCABBACCABCBCAABBC
9
1000000000
1100000000
BBCCACACCCBBACBCCABABAAAABB
10
1111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
0

result:

ok Accepted!!!

Test #21:

score: 20
Accepted
time: 1ms
memory: 3804kb

input:

60 2
1
10
10
CAB
2
110
100
CABCAB
3
0111
1000
CABCABCAB
4
11010
11000
AAABBBCBACCC
5
110000
100000
ACBACABCBABCABC
6
1111000
1111000
AAABBBBBCACCCAABCC
7
11011100
01000000
AAAAACCBCBCBBBCACACBB
8
111000000
111010000
AAABBBBBCCCCCCCABACABABA
9
1011100010
1000000000
AAABAABAABBABBCCCCBCCCCBACB
10
1111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1

result:

ok Accepted!!!

Subtask #3:

score: 0
Wrong Answer

Test #22:

score: 0
Wrong Answer
time: 0ms
memory: 3644kb

input:

60 3
1
11
11
???
2
111
111
??????
3
1111
1111
?????????
4
11111
11111
????????????
5
111111
111111
???????????????
6
1111111
1111111
??????????????????
7
11111111
11111111
?????????????????????
8
111111111
111111111
????????????????????????
9
1111111111
1111111111
???????????????????????????
10
1111...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1

result:

wrong answer Your answer is wrong in testcase 60

Subtask #4:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

0%