QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#637785#5551. Selling RNA Strandsrayan_bd35 465ms84696kbC++202.5kb2024-10-13 14:05:052024-10-13 14:05:06

Judging History

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

  • [2024-10-13 14:05:06]
  • 评测
  • 测评结果:35
  • 用时:465ms
  • 内存:84696kb
  • [2024-10-13 14:05:05]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define all(x) x.begin(),x.end()
#define pb push_back
#define ll long long
const int mxN = 1e5;

map<char,ll> mp;
vector<ll> emp;

struct Node
{
	vector<ll> end_pos;
	Node* children[4];
	bool end;
	Node(){
		end=0;
		for(ll i=0;i<4;++i) children[i]=NULL;
	}
};

struct Trie{
	Node* root = new Node();
	void add(string str,bool beg){
		Node* curr = root;
		if(!beg){
			for(ll i=str.size()-1;i>=0;--i){
				char it=str[i];
				if(curr->children[mp[it]]==NULL) curr->children[mp[it]]=new Node();
				curr=curr->children[mp[it]];
			}
			curr->end=1;
			return;
		}
		for(auto it:str){
			if(curr->children[mp[it]]==NULL) curr->children[mp[it]]=new Node();
			curr=curr->children[mp[it]];
		}
		curr->end=1;
	}
	void update_pos(string str,bool from_beg,ll idx){
		Node* curr=root;
		if(!from_beg){
			for(int i=str.size()-1;i>=0;--i){
				char it=str[i];
				if(curr->children[mp[it]]==NULL) return;
				curr=curr->children[mp[it]];
				if(curr->end){
					curr->end_pos.pb(idx);
				}
			}
			return;
		}
		for(auto it:str){
			if(curr->children[mp[it]]==NULL) return;
			curr=curr->children[mp[it]];
			if(curr->end){
				curr->end_pos.pb(idx);
			}
		}
	}
	vector<ll> qry(string str,bool beg){
		Node* curr = root;
		if(!beg){
			for(ll i=str.size()-1;i>=0;--i){
				curr=curr->children[mp[str[i]]];
			}
			return curr->end_pos;
		}
		for(auto it:str){
			curr=curr->children[mp[it]];
		}
		return curr->end_pos;
	}
};

void solve(){
	mp['A']=0;
	mp['C']=1;
	mp['G']=2;
	mp['U']=3;

	Trie pre,suf;
	ll n,m;cin>>n>>m;
	vector<string> vec(n);
	vector<pair<string,string>> pr(m);
	for(ll i=0;i<n;++i){
		cin>>vec[i];
	}
	for(ll i=0;i<m;++i){
		cin>>pr[i].first>>pr[i].second;
		pre.add(pr[i].first,1);
		suf.add(pr[i].second,0);
	}
	ll idx=0;
	for(auto it:vec){
		pre.update_pos(it,1,idx);
		suf.update_pos(it,0,idx);
		++idx;
	}
	for(auto it:pr){
		vector<ll> c1=pre.qry(it.first,1);
		vector<ll> c2=suf.qry(it.second,0);
		if(c1.size()>c2.size()) swap(c1,c2);
		ll ans=0,nwst=0;
		if(c1.size()==0||c2.size()==0){
			cout<<ans<<'\n';
			continue;
		}
		for(auto it:c1){
			ll st=nwst,en=c2.size()-1;
			while(st<=en){
				ll mid=(st+en)/2;
				if(c2[mid]==it){
					++ans;
					nwst=mid+1;
					break;
				}
				if(c2[mid]>it) en=mid-1;
				else st=mid+1;
			}
		}
		cout<<ans<<'\n';
	}
}

signed main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 0ms
memory: 3576kb

input:

100 100
A
G
AGC
AUA
C
CCA
CGGAG
CCGAG
GACA
UCAAC
CUUAU
AC
A
CGUA
UAUG
UGCGA
GCU
GUUAU
UAAU
A
UAA
U
CGCCC
GCG
U
AUUC
GACA
CC
AG
GUCGU
UUCA
AGGC
G
CU
UG
CUUA
CUAU
AA
A
GUUG
GGU
UU
C
GCUG
C
GUGGA
C
UAU
UAG
GC
GUU
GC
UCUCA
U
AA
AG
C
GGU
GC
CCUG
CCUU
GG
CAGCU
UAGGU
GGCUC
CUACG
UGC
UU
UAAUG
UGGCA
CAA
UGAG...

output:

9
1
11
1
1
2
4
3
11
6
1
2
1
1
4
2
1
11
10
1
5
1
1
1
1
11
1
13
1
1
3
1
11
1
11
11
1
2
2
1
1
10
1
1
1
2
4
2
1
13
10
1
1
1
2
1
1
4
1
2
1
1
9
9
13
2
1
2
9
2
1
10
2
2
1
9
1
1
1
1
1
1
1
9
1
1
11
11
1
1
1
1
2
13
1
2
1
13
1
1

result:

ok 100 lines

Test #2:

score: 10
Accepted
time: 0ms
memory: 3648kb

input:

100 100
U
CUAG
AUCA
UAACG
U
GG
CUCCA
G
G
UGCCA
CGA
ACAAU
GUUA
GUAGA
AUCU
C
GC
ACACG
UUG
CCC
U
UUGUC
AUC
GAA
U
CGGA
U
AGA
GCU
AAG
CUA
UCGG
GGG
UCG
GGAU
U
CGA
CCAUG
ACG
G
C
CUU
GUCU
UUAU
UACU
UCC
UGAAG
GCAAU
CUCG
GAG
U
ACC
CUAU
CU
UU
AAGUA
AGGU
CGAA
U
GCU
AA
CAA
G
UAGGG
A
UCU
A
AA
G
UAC
GC
CAC
AGUGA
U...

output:

1
5
1
8
14
1
5
1
12
1
2
2
12
1
1
6
8
1
1
4
5
2
1
1
3
1
1
1
2
2
1
1
2
1
1
14
1
1
1
1
2
1
2
1
1
14
1
1
2
8
1
14
2
12
1
1
1
7
1
2
1
1
12
5
1
1
1
2
12
1
1
14
2
8
1
1
1
6
3
1
2
1
5
12
1
1
1
1
3
1
1
12
14
1
14
1
4
1
2
14

result:

ok 100 lines

Test #3:

score: 10
Accepted
time: 0ms
memory: 3612kb

input:

100 100
GACC
CACCU
GGCC
UGUA
UCAG
UUUGU
GU
AGUAC
ACUG
UAGAG
UCAA
GGCA
G
GGUU
CGA
A
G
UUUGG
CGA
UG
AU
GAC
AA
GGGA
AGA
AC
AGCAG
AGU
A
UUUAA
G
UGC
ACGUC
A
AUAAA
UAAAA
CGU
AUGAC
GAUA
UGUCC
AACU
AAUA
CUAA
C
CG
G
GGC
UGACC
AUGU
U
UA
GAAUA
AG
UA
UGGAC
AAG
CCGC
UA
CGCAA
A
CCG
UAAAA
GAG
CGG
UA
GAUG
GGA
UCAUU...

output:

2
4
9
9
1
3
9
1
6
11
1
1
1
1
1
11
2
1
2
9
4
5
1
2
1
11
3
1
4
2
1
1
9
1
11
1
11
4
11
1
2
9
1
1
1
1
1
1
2
1
4
1
1
4
9
9
3
11
1
1
1
1
3
5
6
1
2
1
4
1
2
2
6
9
1
1
5
1
4
3
2
1
1
4
10
1
2
1
2
2
11
2
1
1
2
3
1
1
1
1

result:

ok 100 lines

Test #4:

score: 10
Accepted
time: 0ms
memory: 3576kb

input:

100 100
CCG
UAAUA
AGUUU
GAG
GUAGC
A
AAUC
UC
ACCC
A
U
UCGG
AG
G
AG
AC
AAGAA
GCGAU
CGUC
G
AG
UUAAU
CGUGU
GUCG
A
UA
AU
GAAAC
AUG
CGUG
ACGG
G
C
AUG
GAUU
ACGG
GGA
CU
UG
U
AAA
C
UAUGU
UAC
CUA
ACC
CGAUG
GCC
UACG
CCA
UAAU
UUAAA
C
UA
GACA
UUGUC
AGCU
UCCA
AAAA
CUUA
GU
UCCGA
C
UUU
AG
UC
UAAU
GGG
CUCCC
C
UUU
UG...

output:

1
1
2
4
9
1
2
2
2
12
1
1
10
2
10
4
12
5
2
1
1
10
8
4
2
5
8
1
1
4
1
3
9
1
1
1
1
2
4
9
2
4
2
2
1
1
1
8
1
1
1
9
1
7
4
1
4
8
1
3
8
10
4
8
8
2
2
4
2
9
2
2
1
1
1
1
1
1
1
2
2
2
1
4
2
9
2
2
8
9
1
2
2
8
6
4
4
12
2
5

result:

ok 100 lines

Test #5:

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

input:

100 100
CAGAA
CU
GAUCU
AAAC
AUGGG
CCUAC
G
C
A
UC
UUCAU
GUCAA
UUA
GG
UG
GCU
GGGCU
UUUA
CAG
G
G
AAUU
ACAU
AUAC
UA
C
UUCC
CA
CUC
A
UA
GGUC
UGG
AGG
GUUCU
AA
ACCC
CAUG
CGCA
A
AU
GAGGU
GG
UCU
AA
AGUC
AGC
AACUA
CUGAC
GGACU
CCGG
AGGA
GAG
UAAG
GA
ACGA
A
UCUGG
CAG
GCAA
GAG
CC
UAAUC
UUGA
AG
U
GGG
AAACG
UA
ACGA...

output:

1
1
13
1
1
1
2
2
1
2
1
1
2
1
8
8
8
1
2
2
4
2
2
2
2
1
3
2
1
2
4
1
1
5
13
4
1
6
13
2
2
10
1
2
2
2
1
5
10
1
1
8
8
8
1
10
1
1
4
3
2
10
3
1
1
5
2
1
5
1
2
3
1
6
1
1
13
1
10
2
2
1
1
1
1
13
3
10
3
2
1
1
2
2
2
5
1
2
10
1

result:

ok 100 lines

Test #6:

score: 10
Accepted
time: 0ms
memory: 3836kb

input:

100 100
UG
G
AA
GA
G
ACAC
GGAAG
GAGU
UG
UUAA
UG
U
AGUUA
CA
C
G
CCCG
U
UAAG
UCUG
CGGU
A
CAC
ACGA
CA
A
UC
GAAUC
A
GAGG
GG
GGG
CCCUC
GACGU
GGUG
GCG
CCAG
C
AUAU
A
AG
UGU
UCGC
UC
AUA
ACGCC
A
GCUA
CCU
G
AGC
GG
GCAUG
GGGUG
C
CCCC
GG
A
AG
AC
UA
CACG
AU
GAG
G
GG
GACC
ACAAC
GCGUG
C
GAA
C
UGCU
GC
ACGGA
AUG
GCA...

output:

14
1
7
5
1
4
7
1
24
4
14
24
1
4
7
1
1
24
1
1
1
4
7
6
3
1
14
4
1
1
1
7
7
6
14
1
24
1
9
1
1
24
7
24
14
9
1
1
1
1
7
9
24
24
7
5
1
3
24
1
1
24
1
3
2
1
9
4
2
2
1
14
7
5
14
14
1
1
2
2
4
24
2
14
1
1
14
3
9
24
7
1
1
4
1
24
9
5
4
14

result:

ok 100 lines

Test #7:

score: 10
Accepted
time: 0ms
memory: 3644kb

input:

100 100
AG
ACACC
GAG
GG
C
AC
AGCA
AAUGU
AGU
UUA
UG
UAC
UU
U
G
G
CUAA
CCG
AAGU
G
CAAU
CCCUA
CCG
G
GACAA
C
CCCAA
UUUCG
UG
C
AAUGC
GCA
A
C
AAUCC
UCGC
UG
GU
GUAUG
CUGG
UUCA
AC
AACU
UA
GAAG
CGGC
ACU
GUAAU
GGGGA
UGAUU
GCA
CUGAG
CUA
UUGGU
GC
CCA
GCAU
AC
U
GG
UGCA
CUACC
GAUAC
UACG
CAUC
GG
GAG
CAU
AUAA
UUA
C...

output:

2
6
1
1
2
13
1
1
4
1
3
2
2
1
1
6
13
1
1
6
2
11
1
4
1
1
8
3
4
1
1
2
2
1
6
1
1
1
3
11
2
2
2
1
1
6
1
6
1
1
8
1
1
1
3
1
2
2
1
1
4
8
1
1
13
1
3
2
1
1
11
3
13
1
1
11
1
4
2
1
13
2
6
11
1
1
6
3
1
1
13
4
3
6
11
6
3
1
1
2

result:

ok 100 lines

Subtask #2:

score: 25
Accepted

Dependency #1:

100%
Accepted

Test #8:

score: 25
Accepted
time: 55ms
memory: 20488kb

input:

2000 2000
ACUGGAACAGAAUCGUUCGAAUCAACAUUUCCCUCGCUUUUGGCUCCCCUCAGUAAUCUUUGUAGUACCGGCCUUCGCGAUCUGCGGCCAUCCCCUCCCAGUUGUUCGAGUUAGGGCAUGCUCUGCAGCGUUGAUUCAGUC
ACUGGAACAGAAUCGUUCGAAUCAACAUUUCCCUCGCUUUUGGCUCCCCUCAGUAAUCUUUGUAGUACCGGCCUUCGCGAUCUGCGGCCAUCCCCUCCCAGUUGUUCGAGUUAGGGCAUGCUCUGCAGCGUUGAUUCAGCAGAUCCUA...

output:

10
54
331
2
46
42
51
21
6
200
111
211
34
70
7
4
1
57
3
9
351
182
3
65
11
3
25
65
101
24
71
310
62
13
294
2
32
139
18
390
14
78
23
299
47
29
1
7
18
95
32
37
39
53
45
18
288
10
76
75
74
3
24
67
31
9
8
3
77
209
20
40
41
34
10
31
12
14
38
199
22
31
164
35
101
11
26
4
4
9
9
25
13
52
12
99
75
214
7
42
53
...

result:

ok 2000 lines

Test #9:

score: 25
Accepted
time: 105ms
memory: 28644kb

input:

5000 5000
AGUGUGCCACUCUAGAAUCCAAGACAGCAUAACUCUGAUCCCGCUAGAUCGUGCAGCCCCGCCGAGAGCAGCGUAGUAGGUCAGUCAUAGGGCUAGACUGAACGGGUACCGCAUACGGUACCAUUGACGGCUGGACCGAUUGCUCCAAGAACGCAAAAGCGUUAGUUGCAUACGGUGAAAGGCCGCCCUGAACGCCACCUUGCAUAAACCGACUACGUCGUAAGAACUGUCCUAGGUAGUGGAACAUCGCAUAUCUAUGCUCGCGUCAGUAUAACUUUGGCUGACUGGUC...

output:

213
82
24
19
271
71
25
167
34
34
17
7
18
14
40
39
33
53
487
126
50
1005
283
30
69
6
327
48
107
103
17
48
15
259
321
41
9
84
34
244
217
41
556
73
42
117
3
122
6
179
261
21
10
61
199
114
265
95
37
30
163
30
113
66
7
152
119
39
3
77
58
458
18
28
12
383
43
224
31
214
11
25
96
127
387
82
253
90
323
6
246...

result:

ok 5000 lines

Test #10:

score: 25
Accepted
time: 74ms
memory: 24856kb

input:

3200 4998
GGCCGAUAGGAACGUCUUCCUUCUAAACCACAGGUCUUUUGACCGCUGCUACCCCAUUCGAUAAAGUAGUCCACGG
AGUAUGUACGGCUCUUACAAUAAAAGGUAUCGGGAUGUGUAUGAACUGACCGCAAGAUCGACAUGUUCGUCUGCACUUCUAUGUUCGUAUCUCUGAGCCACGCGGUUGCCCGGCGUUAGCGCCGGUCACAGUCGAUUUUGACUAUAAUCAUUUUGUCCUGUUGAACAUAAGCACUGCAAUGCACGCGAGAGGGUGGGGCACGCUGUUCGGCAG...

output:

68
21
24
176
183
41
30
360
95
163
136
119
245
23
21
54
11
148
19
43
16
46
572
106
111
8
415
18
66
97
382
401
186
515
188
169
168
13
142
22
19
221
246
19
417
316
232
16
232
314
124
412
735
53
667
239
111
35
148
115
12
545
276
73
551
405
74
7
120
221
25
17
15
239
346
39
185
27
92
549
380
350
425
22
10...

result:

ok 4998 lines

Test #11:

score: 25
Accepted
time: 95ms
memory: 28188kb

input:

5000 5000
UGGACUAGCUAAACUGUGGAACAUUCUCUAGCUUAUAAUGAUUACCAGGCACAUCAUUCCGUGCGGUUGGAGGUUAGGGACCCACAGACCUCCUAGAUCUUUCCGUUGAACAAUGACACUUCCGCAGUGUUUAUCUACGGAGAUCACCACUUAUUGUCACCUACGUUAAUACUAGACCCACAGUGGCUCAUAAACGGUCUAGCUCCGCGCCAUCAUAACAGGCAGUUAGUCGUAGAUCUGAUAAGAGCGUCGUAGAUCGGGGAAGCGAUUCGAGCCAGCCACAUUUAUAC...

output:

18
495
27
467
43
132
61
80
121
60
10
325
235
136
116
939
5
53
72
58
852
151
28
39
26
440
421
84
70
26
186
458
169
8
163
53
720
376
21
40
145
123
18
64
123
64
109
196
18
31
108
166
433
8
102
386
266
5
158
104
160
283
191
798
166
48
19
631
567
8
21
80
5
329
403
5
11
55
8
89
78
14
33
52
1126
46
19
666
...

result:

ok 5000 lines

Test #12:

score: 25
Accepted
time: 74ms
memory: 78072kb

input:

5000 5000
GGUUAAAUAAUGGUAGUUCUCAAUGGUAGGGUUGUUCCUUAGCUUCGGCGUAGGUUGUCUACAGGUGUGGGGCGGCACCAUGCUGGGCCCGUAGAACGGACCGAAUCGUGGGUGUGAUUUGCAGUAACAUCUGCGGCUAACAAGGAUCGCUAACUUUUAAUCUCAGUACGGAUCGAUGUAGCUAGCGGUUGACCAAUUCCUAUAUCUUCAAUACCCACCUUCCUCUGGGAUUAAUUAACUAAGAGGCACAUCUCAGGUGCCAACGACUUGCUACCCAGUUUCGCUAGACG...

output:

1
1
1
1
1
1
1
1
1
348
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
323
1
75
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
308
4
1
1
1
1...

result:

ok 5000 lines

Test #13:

score: 25
Accepted
time: 83ms
memory: 77180kb

input:

5000 5000
GGUCGCACAAAUCUCGGAUAGGAUACUUCUGCACAGCUGGUGGCUAGCUGGGCUAGCCGGCCGCCGAUGGUUCAAGUUCGGCCAGUUCACCCUAACCCAAGACAACCCGCAAUGGAGGGAUACAGGACGGCUGGCCAGGUUCUCGAGCUUAUCU
GUUAUACUUGUUCCUUGGUAGCAUAGUGGCAUUUGUCGUUAUCGGUAAUUCUUAUUAUACUCGCAGGUGUCUCUCCCUUGGACGGGGCGCGGCCAAACGAAGGAUAAGCGA
GGUUUAUAAGAAACCUUCAGCGA...

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
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
4
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
6
1
1
1
...

result:

ok 5000 lines

Test #14:

score: 25
Accepted
time: 160ms
memory: 39228kb

input:

1731 5000
A
AA
AAA
AAAA
AAAAA
AAAAAA
AAAAAAA
AAAAAAAA
AAAAAAAAA
AAAAAAAAAA
AAAAAAAAAAA
AAAAAAAAAAAA
AAAAAAAAAAAAA
AAAAAAAAAAAAAA
AAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAA...

output:

1155
635
1170
1270
1379
723
678
999
1248
974
1314
752
1719
1304
1717
1651
1485
640
1528
587
1445
1710
1054
987
1448
544
1508
1006
1114
1213
1490
1034
720
617
1666
959
1695
1580
851
1484
675
1118
1375
844
951
1183
1622
1417
1028
933
749
1008
1475
563
1423
1638
1154
689
1243
990
640
1567
1606
550
1237...

result:

ok 5000 lines

Test #15:

score: 25
Accepted
time: 95ms
memory: 84696kb

input:

5000 5000
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

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
2
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
...

result:

ok 5000 lines

Test #16:

score: 25
Accepted
time: 96ms
memory: 78316kb

input:

5000 5000
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

output:

1
3
1
1
1
1
1
1
1
96
1
1
1
266
1
266
1
1
1
1
1
1
1
1
3
1
1
1
2
1
1
1
1
2
1
2
1
2
1
1
2
1
1
1
1
2
2
1
1
1
266
1
1
96
1
1
1
1
3
1
1
1
1
1
4
266
1
1
1
1
1
1
1
1
1
2
1
1
1
1
2
2
1
1
1
1
1
1
2
1
1
1
1
2
266
1
1
2
1
1
1
1
2
1
1
1
2
1
1
1
3
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
...

result:

ok 5000 lines

Test #17:

score: 25
Accepted
time: 465ms
memory: 18260kb

input:

5000 5000
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGGCGGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

output:

4998
4998
4998
4998
5000
4998
4998
4998
4998
4998
5000
4998
4998
4998
5000
4998
4998
4998
5000
4998
5000
4999
4998
4998
4998
4998
4998
4998
4998
5000
5000
4998
4999
4998
5000
5000
4998
4998
4998
4998
4998
4998
4998
4998
5000
4998
4998
4998
4998
4998
4998
5000
4998
4998
4998
4999
4998
4998
4998
5000
...

result:

ok 5000 lines

Subtask #3:

score: 0
Time Limit Exceeded

Dependency #1:

100%
Accepted

Test #18:

score: 0
Time Limit Exceeded

input:

50000 50000
UA
UU
AU
AU
UA
UA
AU
UU
UU
UU
UU
UU
UU
UA
UU
UU
UA
UA
UU
UU
UA
UU
UU
UU
AU
UA
UA
AU
UU
UU
UU
UA
UU
AU
UU
UU
AU
UA
UU
UA
UU
AU
UU
AU
UU
UU
UA
UU
UA
UU
UA
UA
UU
AU
AU
UA
UU
UU
AU
UU
UA
UU
UU
UU
UA
UU
UU
UU
UU
UU
UA
UA
UA
AU
UU
AU
UU
UA
UA
AU
UA
UU
AU
UU
AU
UA
UU
UA
UU
UU
UU
UU
UA
AU
UA
UU
...

output:

12440
12410
12410
12440
25150
25150
25150
12410
25150
25150
25150
25150
12440
12440
12440
12440
25150
12440
12440
12410
12410
12440
25150
12410
25150
25150
25150
12440
25150
25150
25150
12410
12440
12440
12410
12410
25150
12410
12440
25150
25150
12440
25150
12410
12410
25150
25150
25150
12410
25150
...

result:


Subtask #4:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

0%