QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#84049#2141. Wheel of FortuneAhmed_Abdelmegeed#AC ✓61ms13708kbC++202.5kb2023-03-05 07:51:172023-03-05 07:51:18

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-05 07:51:18]
  • 评测
  • 测评结果:AC
  • 用时:61ms
  • 内存:13708kb
  • [2023-03-05 07:51:17]
  • 提交

answer

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define el "\n"
#define matrix vector<vector<int>>
#define pt complex<ld>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<ll, null_type,less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update>
using namespace __gnu_pbds;
using namespace std;
const ll N = 1e5 + 5, LOG = 20, INF = 1e18;
const ld pi = acos(-1);
const ll mod = 1e9 + 7;
const ld eps = 1e-12;
int dx[] = {0, -1, 0, 1, -1, 1, -1, 1};
int dy[] = {-1, 0, 1, 0, 1, -1, -1, 1};
ll n, m, k, x, y;
string s[N];
int has[N];
int least[(1 << 27)];

bool mnwr(int bit, int mask) {
    if ((1 << bit) & mask) {
        return 1;
    }
    return 0;
}

int nwr(int bit, int mask) {
    return mask + (1 << bit);
}

int getbit(int mask) {
    return (mask & -(mask - 1));
}

bool solve(vector<int> &idx, int done) {
    if (idx.size() == 1) {
        return 1;
    }
    int next = has[idx[0]] ^ done;
    for (auto j: idx) {
        next &= has[j];
    }
    if (next == 0) {
        return 0;
    }
    char key = least[getbit(next)] + 'a';
    done = nwr(least[getbit(next)], done);
    map<vector<int>, vector<int>> ne;
    for (auto j: idx) {
        vector<int> v;
        for (int i = 0; i < s[j].size(); i++) {
            if (s[j][i] == key) {
                v.push_back(i);
            }
        }
        ne[v].push_back(j);
    }
    bool ans = 1;
    for (auto j: ne) {
        ans &= solve(j.second, done);
    }
    return ans;
}

void dowork() {
    vector<int> idx;
    cin >> n >> n;
    for (int i = 1; i <= n; i++) {
        cin >> s[i];
        for (auto j: s[i]) {
            if (mnwr(j - 'a', has[i]) == 0) {
                has[i] = nwr(j - 'a', has[i]);
            }
        }
        idx.push_back(i);
    }
    if (solve(idx, 0)) {
        cout << "YES" << el;
    } else {
        cout << "NO" << el;
    }
}

signed main() {
    //fast
    //freopen("lis.in", "r", stdin);
    //freopen("bitwise.out", "w", stdout);
    int t = 1;
    int id = 0;
    for (int i = 1; i < (1LL << 27); i *= 2) {
        least[i] = id;
        id++;
    }
    //cin >> t;
    for (int i = 1; i <= t; i++) {
        dowork();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 6688kb

input:

5 2
hello
world

output:

YES

result:

ok answer is YES

Test #2:

score: 0
Accepted
time: 4ms
memory: 6576kb

input:

4 4
idea
play
game
warm

output:

YES

result:

ok answer is YES

Test #3:

score: 0
Accepted
time: 1ms
memory: 6604kb

input:

4 2
game
name

output:

NO

result:

ok answer is NO

Test #4:

score: 0
Accepted
time: 1ms
memory: 6560kb

input:

25 2
qwertyuiopasdfghjklzxcvbn
qwertyuiopasdfghjklzxcvbm

output:

NO

result:

ok answer is NO

Test #5:

score: 0
Accepted
time: 2ms
memory: 6624kb

input:

1 2
a
b

output:

NO

result:

ok answer is NO

Test #6:

score: 0
Accepted
time: 1ms
memory: 6560kb

input:

1 1
a

output:

YES

result:

ok answer is YES

Test #7:

score: 0
Accepted
time: 3ms
memory: 6552kb

input:

4 4
cada
bbbd
dcbb
dcdb

output:

YES

result:

ok answer is YES

Test #8:

score: 0
Accepted
time: 1ms
memory: 6644kb

input:

5 5
adecb
cdeaa
adcce
bdabd
cdaeb

output:

YES

result:

ok answer is YES

Test #9:

score: 0
Accepted
time: 2ms
memory: 6932kb

input:

1000 100
vbycgpycxwmgizifwpyivycyrbnjcsgthqykunyjdcmcrcfdruwnbgtgiafqycbeykxbokhgmvbropvzrodqmkvjtmzezbsvdkjzetrbjjglhmhxkhvthsgiwjesbtdtorthxzebbxrpywzewuxxqdciwoxoqyrakqcjaqyalotajczynooofyjvkeayvmpagfgrofhfpmjzdqzmczpporekgegdzfdneogiywsccewximkqhdrwtaxduywpiaxybmtjmdgfpaifgrghyzoijuuhjsqldrvjffx...

output:

YES

result:

ok answer is YES

Test #10:

score: 0
Accepted
time: 4ms
memory: 6680kb

input:

100000 1
gjmbwnyiyecuvnuawwrdpdelyaofogpginszgnjoxvywvtqptxjvjoejqeftseevpgqlletsqbvgozjxrglohowbeblzaynydpjdrfeynlrdajlmwbgcjlljtatjxyybhrriixhwwmxetpaihphprsvttliuvstgemkambvsqiiavmojbhqxdxgtqyoowxpvaxymzkonvwbkaikdvluwvaxgicqkqonayphhypgusmepscjwcqqvoyuznbtsexgxraxsnulxvxzybwmhwuqawgvemiplgguowgq...

output:

YES

result:

ok answer is YES

Test #11:

score: 0
Accepted
time: 0ms
memory: 6792kb

input:

4 25000
qtix
mfwq
fewc
nuoz
bkus
tjob
cjlx
feuy
vhdd
xkag
ejwq
lewv
srzh
pxwt
yrtp
dfdp
fxhk
tjay
bpmn
cwca
arpx
funa
uqog
fmfs
ifsa
gygz
mkjy
dnpv
fbrh
yvmc
uyim
kiax
gxpa
tbmr
ywqe
prty
bwrd
akcl
sjgy
wukk
bpti
fjiy
gjed
wjhp
oiqx
gbtr
utae
mnvr
yhak
wilj
nrqj
vwbz
xltu
nhkc
mgnx
poxg
xvly
lovs
ri...

output:

NO

result:

ok answer is NO

Test #12:

score: 0
Accepted
time: 7ms
memory: 6844kb

input:

10 10000
semrrqgeyq
laslsriuzc
fektrnjiau
udydynaymj
sxskejbmhh
vknzlaxawl
wzffusgfua
kmajyjubsn
dodzembftu
pqqgsyfiju
gqepvnciws
nygqjywieq
rkgcmcjmuj
dhzysexbva
rgdlvqmcgk
atcfasfsmh
iiiltzmpoy
ngucmoxczv
dqjxpgwfhw
opfkmzxnxc
jecolecvpi
welkwbnieg
oymduzlixy
pholhpbwza
iyujuzcfxc
dmkxccungv
kvgrm...

output:

NO

result:

ok answer is NO

Test #13:

score: 0
Accepted
time: 7ms
memory: 6736kb

input:

10 10000
fgihfcfhid
edcciacjae
aefibffifa
gfiaaagdaa
ccacabbdjb
fajbbddjhf
efhfidbghd
gababhfdid
cefhgfihfc
ebjagjiggj
gagaadbgib
gaeegghfej
begfiigdaa
djeigiicef
cebciaehda
fgddcgddbg
hdeaiadfhj
djjehfdhhg
fbgaecdeca
hhbghcibfh
hjfidgahhb
defeaehhcj
bibeddbgdb
gjfjeccdji
jiedgebhdi
efcdiacfbg
jaceh...

output:

NO

result:

ok answer is NO

Test #14:

score: 0
Accepted
time: 8ms
memory: 7792kb

input:

20 5000
bbbaaaabbaaaabbbbaaa
ababaabaaabbbbababba
aabbaaabaabbaabbbbab
aaaaaaaaabbabbbaaaab
abbabbaabaaaaaaaaaab
bbbaabaababaabbbabba
aabaaababaaaabbabbba
abbbbbabbbbbaaaabaab
aabaaaabbabbaaabbabb
bababaaaabbabaabaaab
babaaaaababbbbbbaaaa
bbbbabbbabbbbaabaaab
abaabaaabbbbaabaabba
baaabbbaabbbabbbabb...

output:

YES

result:

ok answer is YES

Test #15:

score: 0
Accepted
time: 24ms
memory: 7248kb

input:

10 100000
rditknzufp
mxlobxperf
aehzrkmdkl
ykxtgaqksl
wqhxjykaeg
vrdstmpfol
lbskmvesan
csasmfgfgc
wpncgfjdvi
ihsupukwqj
llgwyhhctw
wocklnxiun
zchhkswexq
kggbudufur
jvddrzwzab
zwtobyzvua
kpftzohdou
doinnwhmxh
qktkmgwcrh
monsmtwkzs
dfqzjlvyiq
anmnlnsmel
jycbklbhqg
ckghdtbpwf
pfuaiderfa
diieyrwqdo
mvxp...

output:

NO

result:

ok answer is NO

Test #16:

score: 0
Accepted
time: 36ms
memory: 7184kb

input:

10 100000
aaegbehgfe
fehcccfhdf
hhaegaccca
dgdgeeaehh
egggbahhha
caehcbadgh
geeedfebga
chfadfchbg
gbceheebfg
ahhcahbhfc
begdcedbdf
ahcgghghdf
fbgccedcfg
egeefahega
cbfbbbdhff
chbgecfdfg
afbbdacbfc
ceehcadacg
gadhfgefdb
ahhfdecdbc
ahgaffefha
efebadgdcb
adbfbebhcb
dghfabcbgb
edfbebcbfa
ffeecahdag
ehcg...

output:

NO

result:

ok answer is NO

Test #17:

score: 0
Accepted
time: 4ms
memory: 6568kb

input:

10 15
tzifuvwynt
iiiuejqjzg
iiiicfpkfe
piiikodfrl
qiillngncy
icdirodsvv
itillxjrqy
qumiyrjlex
iizicqgwst
iriihdtcxs
yirepnmnwg
wikiycjsju
iibxjzdrxn
rqiiggalkr
inwsevlurl

output:

YES

result:

ok answer is YES

Test #18:

score: 0
Accepted
time: 4ms
memory: 6552kb

input:

10 215
mzzrnjgojt
zzdzuianwb
rtuxdoimxw
zfgmeybxdl
tzzztajbus
zozzejwrci
dtzzgxbbho
yzznoteska
zzalgupljq
zibzqwkutj
wbzttdtnur
buvnqsmyjw
lzzzypmauw
mzzwxbaocw
znigxkfikm
qzzeejltkg
zvizxqgukl
mzzzbbauut
pzgwmqdcee
wqzjviidhr
lzzzoqlmhx
usgoccliem
zyzzubdenw
zirldxwwmm
zxisttviij
umwzwknurn
zyzqnaq...

output:

NO

result:

ok answer is NO

Test #19:

score: 0
Accepted
time: 1ms
memory: 6868kb

input:

50 1023
rlikiakkkkllqlhhhaonnpeqtyonagizrbhwqjmuauhwsbditf
kshkjkkkzktcpqvzmqqviuqjytfomyoyenpiyoqcwbzrblnniu
kikjkukdzngyocswdclvuwhqquizlilioaexxxoiijstodbnau
anxphbmkqkjeylasslrlilipynsldbyrudhoeaciququmwwpvv
mkdkgkkzeknnpduhnxzarfqvnjgjvglddfbffsgcmuszewondy
karnrekkdkpzstmouqwezesypduwefoqizygi...

output:

YES

result:

ok answer is YES

Test #20:

score: 0
Accepted
time: 1ms
memory: 6896kb

input:

50 1523
llllllobdlacxrmmxmivivzmexhsgkckdofbapaqupnsbegayo
zfellxllfmaeudgusbrjgqtiuwnvkeyguttuqmpjuenwpbxkck
kgtchiplplbftahetnnukkifbrbdurnapvwtgnwfsponwtjmjj
llnelhqlllobuagjncxezkgtuwdhxuhqqanyrzpgmakxqkzjat
ilalaollrlbeyfkeobrmkyyqonzfbxwuiaqfiieabsguwubrte
fcledlllalbydyucfcfikpqetapdtzrdhxvjb...

output:

YES

result:

ok answer is YES

Test #21:

score: 0
Accepted
time: 11ms
memory: 7096kb

input:

50 6023
faurwatlclrziupnmveztgaxtsfzjzvpacdujyjsfmndexbesn
nplldowbcazizuutevfoundzmynzodzgjbesjgztrankxtvvrz
lellllfltlzuarmstfvdzvcwfhkfrfeskqjinqdkwnvybhyavu
lzelglllvlsugtskiemctamwmacayrckiozoszusgfuezeuwqr
llllllklmldinizxciwuegejzhkofgdugahoxivtisettkjskq
ejlillxgllszpdwrbxfpvbsxtjiswnbrtbqtz...

output:

NO

result:

ok answer is NO

Test #22:

score: 0
Accepted
time: 58ms
memory: 12268kb

input:

15 32767
gwggqsoghiqdigg
ocgsdggpgmgtgig
pcqrsgygggqggfg
ggpgoxgggxoubsg
aggaghggggwggge
vggtygggggtdugg
egjghcgxgggqgxg
qmgudjtgjgvgwiu
gcjaggkoagyrcgo
ghgzygbazhgggco
ggfgnggguidgggb
ggeggecgjgcjhaq
gogylcwggygdwgb
glggmogggeguegg
kwbleqsmgiivntj
ggggrxehggysogb
ggggugbgagggggg
gggumgggtxgkltg
geg...

output:

YES

result:

ok answer is YES

Test #23:

score: 0
Accepted
time: 49ms
memory: 12184kb

input:

15 32777
ooyiwfnixldkopo
ofodooomoigooov
ybfoooozogxomcw
vboljwoomoaossj
yooovjoitooouyg
loooroojdoobczo
ooooozkrooooojo
oldopeoyohosfos
joofooaoofhesoo
oybovoooospgoko
oboeoooboofovof
oobeonoogsovoyy
rooxoozoooohvjy
ogemtpooohjoeov
okoooooooyoxotv
wofoosogooxohoo
ooogzkoifobimcv
oojojoojognwqoo
oio...

output:

NO

result:

ok answer is NO

Test #24:

score: 0
Accepted
time: 17ms
memory: 9396kb

input:

15 16383
vtfyyvjabftvttd
tlvtfttttbtlruw
ytboqdttyfqkerr
ttrtztvaswtxtcl
fmanttcvtfvsttu
fntqdjsbmtbqjgu
tttqtrttthttktf
intutjvztvnftsc
tuttmtttttymati
tatttklrtktbufd
ttttttttttemttj
lqtptnntletotkd
tttttieetttxttu
tttthitxtktldtq
tztttgttwztqitj
tgcttttttyludfz
ftubtftbttitftv
tttttttivtcthtm
vtt...

output:

YES

result:

ok answer is YES

Test #25:

score: 0
Accepted
time: 22ms
memory: 9340kb

input:

15 18183
tuataltkuottjto
ttvztyrttttntts
uttfalttitttttu
ttbthrttltttftw
tzvttsttxotttan
ttmtgttzttbttfh
thkvtttctttttqo
tbuectaitketpdk
nxivccttktfadce
dbtvtftxtmtttbh
tbsrttrzjjbzmtv
waptsetxtttttma
siustthtrettttb
tuwmtpwjvtttwtn
ldtqctjtttwvthb
eyttttttitxraon
texltxgtttttcij
tvtvtottttttdtv
gtj...

output:

NO

result:

ok answer is NO

Test #26:

score: 0
Accepted
time: 31ms
memory: 9400kb

input:

15 23383
ztabbbbhzqbabbg
xbfbpylbgeexjju
bpbxfbvbuikzybh
tkabybtgbbbzmbm
bbbobbbbbbbdbbv
mbtbfubjbtnbwly
bnbbbbbbbbbbfmi
bbmbebbsqwdbbbi
eobmwjbbekfbbbc
bdbbborrbbwbqti
rmfdylbpaksbunh
izllibeybubrbjh
yfhbsbbrbkbbeue
nbbbrayrrbwnbbc
hbbybbmbbbbrpbn
sbbbllodbbnkglw
byzyobtimbkbquc
iubajdbbebbqgzi
bcb...

output:

NO

result:

ok answer is NO

Test #27:

score: 0
Accepted
time: 9ms
memory: 6780kb

input:

15 26383
udbbdbbbbbboboj
xxbkbbapbtbcbbm
abhbbbtbfbbabse
boabpebgbvbobbu
cbbkbfgcbubvpbw
bkbbobbbbbktubm
jbzbbbnbbfsbbwd
xgnnsbbbqybkbbx
bnbfbqvybrblrbs
lbiumbbbbcvfbbr
btlzvrzbowbbbrd
bchgbgffwbbtwqg
bbbbvbokbbxbxzx
bbbubbbrbbdbbvr
bhbbymbekbbbbbe
bvsbrfouftbwuba
bqambqbiebaocbr
bkbbbjbzbbubpbn
bka...

output:

NO

result:

ok answer is NO

Test #28:

score: 0
Accepted
time: 21ms
memory: 10176kb

input:

20 16383
rfcoepdlhpakppymgwag
xpppppsspppvppgoowfd
prpypeppppopkqzsqclk
uqvzkpfpqpppppjnykma
pxpomphjlpphsulvqajo
pspcpytwppppppojarcm
pppvpeppqvppppjwfoni
pucpwppgugfpppqdmrsn
pypyapppppspfmfloiql
daopgmpepgtperfxbqyg
opppbgntpypkxcegxgfk
plrppkwyowqtppwvkdbr
pppppdpqpkppppfswhoj
ppripdprhnfupkqbud...

output:

YES

result:

ok answer is YES

Test #29:

score: 0
Accepted
time: 26ms
memory: 10228kb

input:

20 18383
ijttwtttrztxenwraglv
tttprttttvitttwsbavn
tttvmsttttttttddnrrw
tdttulvtbtetttypdllk
ttuttrlnttttfnnxhsjm
ttquttmxthttmiufboku
ntvhtpbqtykthtvpzpgk
ttetectwtttvooykmqde
vittbtttctzbytiuyynv
ttwtttwgpctrttramnmh
ttykjttstttmatpscdln
otmostycetttttpudgnq
trtttkrtcxttttcnmhki
eawjtctttojstthrnb...

output:

NO

result:

ok answer is NO

Test #30:

score: 0
Accepted
time: 26ms
memory: 10248kb

input:

20 18983
fjfnjfffflffgfxromtn
fflfkfffffdzkfwemloi
fffuowfifdffffjdvxym
vffffffubfimffynpmtl
yhfifhqffauzpfqpaiva
oeeefffefqmfsfcywrgg
yfwffnhiffafffcrpvog
fsfiffffffoynektqtrl
qffffhiffcfbfknkncgs
ffdfukfrnqqfxhtsszuw
fofldkffflffegzyppbe
vffufjfzfrfaffphrecm
ffffjxfffbffuftgezsx
srojffmwffmffthlvm...

output:

NO

result:

ok answer is NO

Test #31:

score: 0
Accepted
time: 32ms
memory: 10756kb

input:

40 16383
tetttttwhactqtwzoroxobnxnaoiwkrczhxoqlwu
fbdettwttttzttdlefqjwlbcaqpmzzxkmipgbyra
fhntbqtftwtttfgaopkwscqzmcsmvspezwcqgqqb
tqbgttuxuwsdttpbieygjeurrbxuaprnfujopuyn
rxtuttsmqtmstbyoeujriijqbqmknnblnljnllgo
wetjtttwthjstwssxekmjpklaghgbymscpuvevpb
otttfotwwttmtohaqazjcjlwakcoxcpnrxqliwmn
ayvt...

output:

YES

result:

ok answer is YES

Test #32:

score: 0
Accepted
time: 34ms
memory: 10832kb

input:

40 18383
qqnqqqoqcmoqqqjagisjwijgdonahishfwikgwki
qqqwuqixxqqqqhswirbpmfdosatrnirdfilhkkek
qkjkqsqqqqkqcemdaxigciuvtuyfglfdlteyexvb
qszvxknhqdqqilpcjixcfhedkxwyvhovobrnycha
qqqjqdhqqqqqlqotgotgntzfktxhasxbyrwcyrgg
bitqftkzdxolrnffzogrsyphrepjboynmiyedkul
qcqqqqidagwfhzbzhjdikmvunkopaykdsbsetcmh
mqxq...

output:

YES

result:

ok answer is YES

Test #33:

score: 0
Accepted
time: 61ms
memory: 11292kb

input:

40 24383
tidnpnnnvynnwlbsikmjkicyzujpreejohvhxift
nrnnnncnontnnaovuerizcvzeockwyculxsgezih
nnnolllkannpnertehuktrmsddrvjvcdigozrstw
nnnnreqeuwlionefbvauqdytlvfojbsztaoooubr
enfnsnnspnnznkdopvqlokgtlvcoxpbpohiygyfg
vnqckthfnnzcnnyzqkkskfyuxctobreftgklmixr
utnninnusnnnnhbccxtrlrihequjfizmkkhjscks
nnfn...

output:

YES

result:

ok answer is YES

Test #34:

score: 0
Accepted
time: 1ms
memory: 6564kb

input:

26 27
goqggehggzgvbgjxnumgarfitg
ooqooehoozovoojoouoooooooo
woqgyehkpzlvbcjxnumsarfitk
hhhhhhhhhzhhhhjhhuhhhhhhhh
jjjjjjjjjjjjjjjjjjjjjjjjjj
roqrrehrrzrvrrjrrurrrrrrrr
woqgyehspzlvbcjxnumsarfits
zzzzzzzzzzzzzzjzzuzzzzzzzz
woqgyehdpzlvbcjxnumsarfitk
eeeeeeheezeeeejeeueeeeeeee
loqgyehlpzlvbcjxnumlarfi...

output:

YES

result:

ok answer is YES

Test #35:

score: 0
Accepted
time: 2ms
memory: 6572kb

input:

26 31
nnnnnnnctnnuninnnnnnnonnnn
kzjqmnwctvxupiewydfsaolgrb
kzjqmnwctvxupiegydfsaolwrb
kzjqmnyctvxupiyyydfsaolyrb
kzjqmnectvxupieeydfsaolerb
mmmmmnmctmmumimmmmmmmommmb
jzjjmnjctjxujijjjdjjjoljjb
kzjqmnqctvxuqiqqqdqsaolqrb
vzjvmnvctvxuvivvvdvvvolvvb
cccccccctccucicccccccocccc
xxxxmnxctxxuxixxxdxxxoxx...

output:

NO

result:

ok answer is NO

Test #36:

score: 0
Accepted
time: 0ms
memory: 6668kb

input:

31 151
npytmufdacqolcrirhsjbwrkxezrgrv
npytmufdarqolcrirhsjbwrkxezcgrv
npytmufdacqolrcichsjbwckxezcgrv
npytmufdacqolcrichsjbwckxezcgcv
npytmufdarqolcrichsjbwckxezcgrv
npytmufdarqolcrichsjbwckxezcgcv
npytmufdarqolccirhsjbwrkxezcgcv
spytsufdassolssissssbwskxessssv
npytmufdacqolrrirhsjbwckxezrgrv
npytm...

output:

YES

result:

ok answer is YES

Test #37:

score: 0
Accepted
time: 3ms
memory: 6728kb

input:

31 279
xzwgqoggupnggmsgvgetggajgyhgggi
xzwdqoffupnffmskvgetrfajfyhrlci
xzwdqofrupnffmskvgetrfajfyhflci
xzwdqofrupnrfmskvgetrrajfyhflci
xzwdqorfupnrfmskvgetffajryhflci
xzwdqoffupnrrmskvgetfrajfyhflci
xzwdqoffupnrfmskvgetfrajfyhrlci
xzwdqorrupnrrmskvgetfrajfyhrlci
xzwdqoffupnfrmskvgetrfajfyhrlci
mzwmq...

output:

NO

result:

ok answer is NO

Test #38:

score: 0
Accepted
time: 50ms
memory: 13708kb

input:

38 16407
cajjnbjvjqjfidoulynwjngtjzkespxjrmnhjj
canjjbnvnqjfidoulynwnngtnzkespxjrmjhjn
canjnbjvnqnfidoulynwjngtjzkespxjrmjhnj
cannnbnvjqjfidoulyjwjjgtjzkespxjrmnhnj
cajjnbjvnqnfidoulyjwnngtjzkespxjrmnhjn
canjnbnvnqjfidoulynwnjgtnzkespxjrmnhjj
cajnjbjvnqnfidoulyjwnngtjzkespxnrmnhnj
canjnbjvnqnfidouly...

output:

YES

result:

ok answer is YES

Test #39:

score: 0
Accepted
time: 41ms
memory: 13548kb

input:

37 16407
caffqftsrlffkmnbexpfjgvfpffoifuhfywpd
cappqftsrlffkmnbexpfjgvpppfoifuhfywpd
cafpqptsrlffkmnbexffjgvpfpfoipuhpywfd
capfqftsrlffkmnbexfpjgvppffoifuhfywpd
caffqptsrlffkmnbexppjgvpffpoipuhfywfd
cafpqftsrlfpkmnbexffjgvppffoifuhpywpd
caffqftsrlpfkmnbexffjgvfffpoipuhpywfd
cappqptsrlppkmnbexppjgvpf...

output:

NO

result:

ok answer is NO

Test #40:

score: 0
Accepted
time: 4ms
memory: 6584kb

input:

10 512
hnpesmfkjq
jrlonipqgs
gnperklmis
jhqfsodgmk
grneqljois
flpgsnjkiq
gpnerlhojs
gnpesmhikq
gpoerljmis
hlqfsodkjm
jhpernfgls
jfphrndels
hpnisljogq
fpogrljmis
hpoesmfkjq
jfphrnecls
jpokrhlmis
hlpisnjkgq
ipogsmeckq
hrlmqjnogs
nrkomipqgs
fpoisljmhq
glqesnhiko
lrjmohpqks
hjpernfils
inpgrmecks
jrnkqhl...

output:

YES

result:

ok answer is YES

Test #41:

score: 0
Accepted
time: 4ms
memory: 6564kb

input:

10 513
fhqsrdjkom
girspekcom
ehsqpfjkom
gfsqpjimol
ehsqlfkipn
egqsrhkiom
ehsmjfliqo
gismjdleqo
gfsonjikqm
gfsqplionk
mjsqpngoli
mjqsrniolh
egsqnjimpl
egsqjhlipn
egqsrjionl
gfrspjionl
gfrsnhjmpl
kjsqplgmoi
gisqpekcom
fhqsrdkiom
egqsrniomk
mlpsrnkqjh
eirslfkgpn
egrsphjonl
girsndkepm
onmsrpgqki
ifpsrjh...

output:

NO

result:

ok answer is NO

Test #42:

score: 0
Accepted
time: 6ms
memory: 7128kb

input:

512 512
ssrsprssssrrrrssssrrrsrsssrsrrsrrosorosrppsskjrssorssssspssrsrsprnrsppsssssrmosssssosnrsspssosssnosrsrpsspssrspsssrsspossorspsprrsssnpssosrsssrosrrssrprspssornrrsrssssoornrsorkpsmssmsrrnppspnsjsprsrspsprssssrropsssrprpprsorrspssssgsssorsppsssrssrsrspsmsposnrspsrsprsspskpspsrpsssspsnsspsrrsrr...

output:

YES

result:

ok answer is YES

Test #43:

score: 0
Accepted
time: 7ms
memory: 7212kb

input:

512 513
sssssqmqsssqsmpmsqsqkssspsqsqssoiskssspqqmiqssqsospspsssqsqsssqqssqqqiqosssissspsssssmsqsqsqssqpssossmqqsssksqssmqqpopsqqqsspsmqpqpqqdsqsssmpsssqsqsssokssssqqpokpsssqqsssososppsqoqqqqqqspsssspspqssqssossspsssqssqssoqspssqqqsssppssqpssspsskssksosoqqoqepsqspssqsppssssspsqqpsmpqspsqsgpsmssssssq...

output:

NO

result:

ok answer is NO

Test #44:

score: 0
Accepted
time: 4ms
memory: 6648kb

input:

13 4096
tynwqoxrlpmus
pyjxmkrnvltqo
tymvkixrqjows
tymvikxnrhpws
jwrygpnhvltmi
runykitlwjqso
tyoxgkvlsiqum
twlyomvrqnkus
pwoygmvjuirsk
lupyintgwkrse
pynxikrlvhtqo
psmygkrnwiuqo
lwpyintjvhsqk
pymwkjxnthruo
tynvhlxfsjpwq
nupyglthwjsqm
ryowkjxluhqsm
pwoygmvhujrsk
tylvmjxrqhows
rymwgkxptiouq
jqsyipnfwmuk...

output:

YES

result:

ok answer is YES

Test #45:

score: 0
Accepted
time: 9ms
memory: 6736kb

input:

13 4097
kouiyvxpglnsq
ksrlwvytopjnu
oiumyxwjhfqsk
lmujyvxpghosq
nkwiqpylgjsuo
jouhyvxpknmsq
nivlyrxjhfqto
mivkypxnhfrto
koshyxuvilnqw
jothyxvrknmqw
nevkytxligqso
lsrhyxvtijnpw
nevlwtyjigpsq
lquiyvxrgjnps
muoryxqvstjlw
nkvjypxlghrto
lmvjwtyphfors
ofumyvxdkhqsi
ogwlqpyhjfsum
lmviytxpgjors
iowlsrypmnku...

output:

NO

result:

ok answer is NO

Test #46:

score: 0
Accepted
time: 0ms
memory: 6572kb

input:

10 512
giaekbfhcj
iajdefcbgk
gijeadcbhk
afjckidbhg
gacebihjdk
fhagkicbdj
djceaigbhk
diaekbcghj
gjbeachidk
gajfkidbch
gfjeaicbhk
gejfaidbhk
eacdkihbgj
fjbgachidk
gabekifhcj
gejfaibchk
ejbdahcifk
ehadkicbgj
gabfkiechj
haedbicjgk
eajdficbgk
fabdkchiej
dhjekacgbi
eagjdhcbfk
cgjeaifbhk
gijfabechk
eacdbhi...

output:

YES

result:

ok answer is YES

Test #47:

score: 0
Accepted
time: 4ms
memory: 6648kb

input:

10 513
fgbkadchji
fgakjehcbi
egkjafchbi
gfkjahdibc
eckjhfbgai
edbkachgji
eckhgfabji
fbkhgdaeji
gfkiacdhjb
gfkjaihbcd
dikjacgbef
dibkacfjeh
egkjihdbac
edkjgchbai
egbkahdjci
gfakjhdbci
dfakighbjc
dekjacgibf
fgkjaehcbi
fcbkadhgji
egbkachjdi
deckajfbgh
egakhcbfji
edakjghbci
fgakidhejb
defkacgbji
dfckahe...

output:

NO

result:

ok answer is NO

Test #48:

score: 0
Accepted
time: 4ms
memory: 7208kb

input:

512 512
kkakjakkkkaaaakkkkaaakakkkakaakaabkbabkajjkkieakkbakkkkkjkkakakjacakjjkkkkkadbkkkkkbkcakkjkkbkkkcbkakajkkjkkakjkkkakkjbkkbakjkjaakkkcjkkbkakkkabkaakkajakjkkbacaakakkkkbbacakbaijkdkkdkaacjjkjckekjakakjkjakkkkaabjkkkajajjakbaakjkkkkgkkkbakjjkkkakkakakjkdkjbkcakjkakjakkjkijkjkajkkkkjkckkjkaakaa...

output:

YES

result:

ok answer is YES

Test #49:

score: 0
Accepted
time: 12ms
memory: 7060kb

input:

512 513
kkkkkjijkkkjkiaikjkjhkkkakjkjkkbgkhkkkajjigjkkjkbkakakkkjkjkkkjjkkjjjgjbkkkgkkkakkkkkikjkjkjkkjakkbkkijjkkkhkjkkijjabakjjjkkakijajajjdkjkkkiakkkjkjkkkbhkkkkjjabhakkkjjkkkbkbkaakjbjjjjjjkakkkkakajkkjkkbkkkakkkjkkjkkbjkakkjjjkkkaakkjakkkakkhkkhkbkbjjbjeakjkakkjkaakkkkkakjjakiajkakjkfakikkkkkkj...

output:

NO

result:

ok answer is NO

Test #50:

score: 0
Accepted
time: 9ms
memory: 6680kb

input:

13 4096
cnibfhaelgjmd
cnjafhkemglbd
mnkcjiaefglbd
mnfcijakehlbd
hmkngjieaclbd
clenfiajmgdbk
cnkagfmedilbj
cminlhaefgkbd
kmdngjaebfcli
ilknhjagmdcbe
cneaifkjmhlbd
ckfngjaemilbd
imcnfjleahbkd
knfbjgaechlmd
mnkchjafdiebl
jlcngeahmibkd
cnkbfgaemhdlj
kmdngjahbecli
mngckjaefhlbd
lnkbgjaecifmd
cjkndaifmblh...

output:

YES

result:

ok answer is YES

Test #51:

score: 0
Accepted
time: 3ms
memory: 6668kb

input:

13 4097
fdbinmacgjelk
hdekmancfljgb
jdminabcefklh
ejbinmacghdlk
cdmfjanigeklb
gdbhnmacjeflk
cdminkahefblj
dhminjacefklb
fkmhnadcijelb
gkmhnacljefdb
cemdnlaihgkbj
jdehnacmfiklb
jeaimlnhdgcbk
jdbfnmacgikel
ldmgnahcfejib
cdmenjaighklb
ejaimlnkhfdcb
jfbinmadhcklg
bdmcjanghfkli
ejmfnlakgidcb
idmgkancfehl...

output:

NO

result:

ok answer is NO

Test #52:

score: 0
Accepted
time: 58ms
memory: 8612kb

input:

16 32768
kbomngpfiadqjhlc
piomcdbenhkqafgl
qiomnlpebhkdafgc
qhegfdcnbilapmko
ojadnlpkbghqmfec
oeamndpfkciqlhbj
qjcgdmpeokhbafln
qiodnkpebhgamflc
qjomnkdibefcaglp
mgoanjpebdhqkflc
qhfmjopebigdankc
piocnjbemkgqafdl
qjdmenclbkiapgfo
plghndcebjmqafio
phefndambjkqolgc
qjdmenblokiapgfc
qiofndembgjcaklp
qi...

output:

YES

result:

ok answer is YES

Test #53:

score: 0
Accepted
time: 51ms
memory: 8668kb

input:

16 32769
lmngfcbopkahdjeq
ldniepjhofacbkmq
bgnihpkclfqjodam
djchfablniqeokmp
ldfhiebcanqjokmp
ldejfpbcakqiogmn
longfpbcakdhejmq
licegbnjphadokmq
bdnicphglfqjokam
jdigfpbcneahomlq
ldbfgpmkniajoecq
dkngfpbcleahojmq
gnejfdbcalqiokmp
lenicphgjdqboamk
kdhgfpbnaecmoijq
gdnkfcpmalbhojeq
hdnglcbmpeakojfq
ld...

output:

NO

result:

ok answer is NO

Test #54:

score: 0
Accepted
time: 13ms
memory: 8272kb

input:

1000000 1
clvjbkticbvcfkkkbherajrgntafpfbssakkoojpbnctjhksjrbesgasagwqhjbsuhofsattktwecuoislfcppnejortgpfapjibhmpwtnartgcrsnicwsdpikomiccqcjkqgottgsttjteawfqnfforuqhmsqgglriuiiathntnbckllqfvsurtkougrtjkcqopabwfalticbpafqgdshtcierffmldamiunjfmakbkdqflvnerhucsprboruapdaphmanqeeeljwgfcrvduwjwimcebtkmbt...

output:

YES

result:

ok answer is YES

Test #55:

score: 0
Accepted
time: 38ms
memory: 11148kb

input:

500000 2
ndvodjlqqfahowkkobeqlcbrpmioinveruimhjarsfvadinqmtoksrfeincrwkckprohjnemwmhvlklqfwbjrpjggvmrqhkogabkomtrlefjgbmfprhghetgpkdskstlcadqccruipebihgisnisrninictfctqlvtfvgukmvkudmwhaqamnskbvfpimdbmndlqfrtmvhvpsgeehdmfoenbbtwgcjalqkgubgmiossiwedcbrjocfupeaiqqgwkiwhwvsipouttvdmqafmjasggiovmwrmknqej...

output:

NO

result:

ok answer is NO

Test #56:

score: 0
Accepted
time: 23ms
memory: 8832kb

input:

250000 3
nslfjowdtaailstwiqnbsfropqfacbubpalsdqtnaudvhrplthdidkgcpmqhucowijtqgeftppgplegvtluklwlihwoqtltsmnkndkjiiwibqwhttdmffqfomwjhutvwsafegihdgvrdnlpjpuloiieqcfkwofusvfueeqhopvpwkhpmtlbmvakcfpfdkaaeusprpfqsmnerpvierkktkpfbblkugokdtvfbuqdltnqcfmrkocuaibroppfwnnaqppqqdgqnlmatvrkudiwmotshrqfllwrllmg...

output:

YES

result:

ok answer is YES

Test #57:

score: 0
Accepted
time: 37ms
memory: 9332kb

input:

250000 4
mkqjeqepmkkivjmfpbumelmmhlkahhtoajwajmtfbdpppciapqrcfswdsdsouofptpisfqoqmnovthvbjptighlleeckkkqkjbppemfnqnfsdkolaejnkblthrfdncirrntbcnecmmvphhlojpspfdckgpvgqvmcljusulhkrrkskhnrtjsdmcvvrbkcsfekjvdlilwquhklfbhalenbjflpjcanvwwwvenjjckkrcevpfocwoebvlbjsvmpmfsjulemaqrcetpdloiwktfkfkvsmamvftuqeif...

output:

NO

result:

ok answer is NO

Test #58:

score: 0
Accepted
time: 33ms
memory: 7928kb

input:

100000 7
ksdtdprksvsvgmodtfrgjbfobqklrvbcakctrjslvrlodnwfqktrljujpifmrdklmpwshddidplkbbwuwutsgghvcgnqfiscphovdvbkrisrtsfqaubjedtfffreeaosoeptwifjeaaerieufedaaqpnrfrulvdejpqplwwergioivieisaurslowivrkaorssranvsulvchkmmpucgqbjpbmrvakpgadalwhjvsrblokcduqnbpnqunctveqvaotvgjpippcmoeuiiakqelhomfrwnqfmvfkeo...

output:

YES

result:

ok answer is YES

Test #59:

score: 0
Accepted
time: 31ms
memory: 8156kb

input:

100000 8
wntgmqqoearowqpwjuiqfgalbutkgsgvssgfvsrohbniridtvressbjtdvmtrkjammlckokltswjhffebflntpkrlalpwkmifjgpaultfecjjpvndhvrsfbtpwcquthagemjfmupdglaqsceegbetolftkvehduoikaqsqdermatlhiovcgrhseoqfocrvdclhqilhkrdrguqeaktugbnpdcqucielrvrfdvvtmqucijfcgmrlhiofdoifdvtuqgvbqghmevtgesmquicfcvlbngcusrktifqrd...

output:

NO

result:

ok answer is NO

Test #60:

score: 0
Accepted
time: 28ms
memory: 7932kb

input:

666 1023
vevffaymhchdvgbicwpcdujtlrfbokvtutgasahvotseotludnfikwtpsnnjkiccmievtduqlkqqwgghoobwkrittqxhfhypitgphmttukvbclffjepniqtgcpkiuneimpfidsohjruoidjcrtdbxebridvbnnjckpohfselkfiphwiutlpnuadhkcrvuicgbjnmptruiemoqiewtlnjmrwletmsgtgqeisashjvcdafxvkcfefmimvrbbkkqmwqotpshrenwcuivvceciqbnkeknuoshkqkcmn...

output:

YES

result:

ok answer is YES

Test #61:

score: 0
Accepted
time: 39ms
memory: 7844kb

input:

777 1030
mbatjrkgajduyqpsepgvavajjlafsvdsivvoattfhmheuphalohjqbauqaehfdlgyubirtibfjgppautubtwiimpswhhkqtpgvvsjsslvdtvilikcjwqvdohgeskhwyrengeivfwthdtlndlnepdgpnjtcbmgconoqjnvpvkbvodrfdnieqrujseashorpwejvieasigmdujnumfwqiobhcqqwlwftvuewgahhnbursvximlnaldoerbslhfflwspuqfrlmpdopeqkhxjhsqjvamfdweqwjaalo...

output:

NO

result:

ok answer is NO