QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#166895#6516. New but Nostalgic Problemucup-team134#AC ✓82ms30536kbC++144.1kb2023-09-06 20:16:212023-09-06 20:16:21

Judging History

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

  • [2023-09-06 20:16:21]
  • 评测
  • 测评结果:AC
  • 用时:82ms
  • 内存:30536kb
  • [2023-09-06 20:16:21]
  • 提交

answer

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

#define ll long long
#define pb push_back
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ld long double
#define li __int128

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<int D, typename T>struct vec : public vector<vec<D - 1, T>> {template<typename... Args>vec(int n = 0, Args... args) : vector<vec<D - 1, T>>(n, vec<D - 1, T>(args...)) {}};
template<typename T>struct vec<1, T> : public vector<T> {vec(int n = 0, T val = T()) : vector<T>(n, val) {}};
template<class T1,class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a){os << '{';for(int i=0;i<sz(a);i++){if(i>0&&i<sz(a))os << ", ";os << a[i];}os<<'}';return os;}
template<class T> ostream& operator<<(ostream& os, const deque<T>& a){os << '{';for(int i=0;i<sz(a);i++){if(i>0&&i<sz(a))os << ", ";os << a[i];}os<<'}';return os;}
template<class T> ostream& operator<<(ostream& os, const set<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T> ostream& operator<<(ostream& os, const set<T,greater<T> >& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T> ostream& operator<<(ostream& os, const multiset<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T> ostream& operator<<(ostream& os, const multiset<T,greater<T> >& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T1,class T2> ostream& operator<<(ostream& os, const map<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
int ri(){int x;scanf("%i",&x);return x;}
void rd(int&x){scanf("%i",&x);}
void rd(long long&x){scanf("%lld",&x);}
void rd(double&x){scanf("%lf",&x);}
void rd(long double&x){scanf("%Lf",&x);}
void rd(string&x){cin>>x;}
void rd(char*x){scanf("%s",x);}
template<typename T1,typename T2>void rd(pair<T1,T2>&x){rd(x.first);rd(x.second);}
template<typename T>void rd(vector<T>&x){for(T&p:x)rd(p);}
template<typename C,typename...T>void rd(C&a,T&...args){rd(a);rd(args...);}
//istream& operator>>(istream& is,__int128& a){string s;is>>s;a=0;int i=0;bool neg=false;if(s[0]=='-')neg=true,i++;for(;i<s.size();i++)a=a*10+s[i]-'0';if(neg)a*=-1;return is;}
//ostream& operator<<(ostream& os,__int128 a){bool neg=false;if(a<0)neg=true,a*=-1;ll high=(a/(__int128)1e18);ll low=(a-(__int128)1e18*high);string res;if(neg)res+='-';if(high>0){res+=to_string(high);string temp=to_string(low);res+=string(18-temp.size(),'0');res+=temp;}else res+=to_string(low);os<<res;return os;}

void test(){
	int n=ri(),k=ri();
	vector<string> s(n);
	rd(s);
	k=n-k;
	vector<int> inds;
	for(int i=0;i<n;i++){
		inds.pb(i);
	}
	string ans="";
	for(int i=0;;i++){
		vector<vector<int>> ok(27);
		for(auto p:inds){
			if(sz(s[p])>i){
				ok[s[p][i]-'a'].pb(p);
			}
		}
		inds.clear();
		for(int j=26;j>=0;j--){
			if(sz(ok[j])<=1){
				continue;
			}
			//printf("%i %c: %i %i\n",i,'a'+j,sz(ok[j]),k);
			int treba=sz(ok[j])-1;
			if(k>=treba){
				k-=treba;
			}
			else{
				//printf("NO!\n");
				ans+='a'+j;
				vector<int> newInds;
				for(int k=j;k>=j;k--){
					for(auto p:ok[k]){
						newInds.pb(p);
					}
				}
				inds=newInds;
				break;
			}
		}
		if(sz(inds)==0){
			break;
		}
	}
	if(sz(ans)==0){
		cout << "EMPTY" << endl;
	}
	else{
		cout << ans << endl;
	}
}
int main()
{
	int t=ri();
	while(t--){
		test();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3748kb

input:

2
5 3
gdcpc
gdcpcpcp
suasua
suas
sususua
3 3
a
b
c

output:

gdcpc
EMPTY

result:

ok 2 lines

Test #2:

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

input:

20000
5 3
apveofpr
irdbqk
rnionnjjrk
wrpihlsw
ofylfsriof
5 4
iiltghqg
kybhogptqf
jfnmqxzrdq
rpztcluq
tzmnrcjae
5 5
ysp
vujmkkcutl
ksawqeiiaf
waukilaq
wmlsutlued
5 3
pikybt
yiqmqvtjeq
tyrsoihf
vnvjrxpus
cuubpacubb
5 2
rihuvikhg
twrsuoervz
ukiekoohw
eysqgndpf
sxswpeqtaf
5 5
vxzhicbp
nvtdbgqal
jilppvpt...

output:

EMPTY
EMPTY
w
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
o
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
t
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
w
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPT...

result:

ok 20000 lines

Test #3:

score: 0
Accepted
time: 16ms
memory: 3812kb

input:

1000
10 9
wkpbdhbivgksnwvnqnynzrmhowmpbbtswjydwidifwuquenplmozlqnkxqefckyzcughrdbturdzsxrcggpzrtrvlewigox
qbxgxomnfarjtvfbxbabtpmhnuwvbxfpwpkjuzjsehofemfzxglvvthzgkzukwmlyfhajchvphdjfqmfubwwpdtdbjpfvk
qrsovcdbphsndcmjwxjhmktwvgakzqewnoymumlawlmmgjmbpivccldrrfgspjypwosdqgpyqnxhaukwycqntuxglbdwf
fbdtn...

output:

q
EMPTY
EMPTY
EMPTY
h
EMPTY
EMPTY
EMPTY
h
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
v
b
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
t
EMPTY
EMPTY
e
EMPTY
b
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
b
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
v
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPT...

result:

ok 1000 lines

Test #4:

score: 0
Accepted
time: 82ms
memory: 3676kb

input:

25000
10 8
phl
vwel
ufme
dtsf
con
giby
xlma
dhke
zjir
itws
9 5
qtgd
wcqj
ixmz
swv
myxo
eqq
yxiq
uvb
spbw
10 7
xrkp
ze
smt
nq
ijhw
lmxf
kcgs
hi
qwmq
hilw
8 7
rlf
taaq
hmdu
thex
dbb
spcp
awyn
khdu
10 10
voxx
tqv
ehtx
xctk
zamh
zua
rbyg
bmeh
wmiv
cmw
9 6
bzq
ayz
cdna
myi
rdeu
gtdo
ycy
sjec
ystp
9 4
tix...

output:

EMPTY
EMPTY
EMPTY
EMPTY
z
EMPTY
EMPTY
s
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
y
EMPTY
EMPTY
a
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
m
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
g
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
j
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
j
EMPTY
t
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
EMPTY
...

result:

ok 25000 lines

Test #5:

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

input:

1
898 840
fdefauodwerznqpzszernrspbndmdfkjrbazmworfvlfbxwcprhxenouzxirrhqtwgiwdcejexotjetwgzqlqtndynfzwmfakfeojtxwrvekebmudrouskcgpzncnsxwajwaoclvqnaycgaaktqctsmbnosbajzryxpxzxuwnzpvmyfobgogbllqyxplageeufjjnrlhairtetyridmhthpplivokbinfmblugrzkcyxuhewtyoxkfzmyhgsbafmgqazoqollibsxlprjneeqursjuomypstme...

output:

y

result:

ok single line: 'y'

Test #6:

score: 0
Accepted
time: 48ms
memory: 30536kb

input:

1
666416 645656
d
j
s
g
s
b
w
x
b
z
v
m
c
o
h
a
j
v
v
l
y
i
l
n
g
x
u
q
d
m
z
q
k
n
l
c
v
n
q
b
y
g
t
c
q
i
k
b
z
i
h
e
c
b
h
e
v
a
n
c
n
z
b
g
c
n
m
f
x
q
y
b
l
h
r
a
i
g
v
e
q
k
u
e
z
q
a
a
a
c
g
d
c
d
f
n
i
d
l
d
w
i
h
p
b
a
u
n
i
e
z
l
v
l
a
y
t
k
j
y
z
r
f
c
o
f
x
w
p
y
q
a
j
v
j
n
t
f
m
j
j
z
...

output:

z

result:

ok single line: 'z'

Test #7:

score: 0
Accepted
time: 14ms
memory: 4812kb

input:

1
10 8
tahlarajyplchghlbufhsanuvbmsafotmdanvtsltpignbmcydrndrjteyjjphxzxjcsqnszqxhmcyvujrfdispekvglqxyeflsvdssvmrkfjvyydknxjcyekcstfzgpnznkupdsaesmhakazgshvycwwctjnwxhhdokcujhwnqrqyqnvfikaofgwyxfcphgpkayzzwgcmceycippdyvibeqqibhemzeucugdtwlljqejewmapdajieanbukrpeqfzlcqblbkbemvcvkdnwshnbhymextgudifvju...

output:

tahlarajyplchghlbufhsanuvbmsafotmdanvtsltpignbmcydrndrjteyjjphxzxjcsqnszqxhmcyvujrfdispekvglqxyeflsvdssvmrkfjvyydknxjcyekcstfzgpnznkupdsaesmhakazgshvycwwctjnwxhhdokcujhwnqrqyqnvfikaofgwyxfcphgpkayzzwgcmceycippdyvibeqqibhemzeucugdtwlljqejewmapdajieanbukrpeqfzlcqblbkbemvcvkdnwshnbhymextgudifvjupdzdlne...

result:

ok single line: 'tahlarajyplchghlbufhsanuvbmsaf...zlcmnrtuhonflpulivygwfecgknnhvx'

Test #8:

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

input:

1
10 3
fbggdpqikbolemnowgfpwwouvbmhhxhecicbinhjesduugcuztgbjleluktdtbpcjfrwowpjfnkutjiffhdgygavviinleqwungdnykbnhrnccqnzbtaaouommlictujvlytueosbalqanancqjojunivkmzbhnggvraxlyowgdovaogsqdzxutwmcqwqrawlnxagzztmsxvrmhsrybddgtpboflhbbojoiolrhmhrvgyxuputssivbrlsdxvwbraxxtgugamtcorgeiazpvomjlkefldsvntaxpf...

output:

fbggdpqikbolemnowgfpwwouvbmhhxhecicbinhjesduugcuztgbjleluktdtbpcjfrwowpjfnkutjiffhdgygavviinleqwungdnykbnhrnccqnzbtaaouommlictujvlytueosbalqanancqjojunivkmzbhnggvraxlyowgdovaogsqdzxutwmcqwqrawlnxagzztmsxvrmhsrybddgtpboflhbbojoiolrhmhrvgyxuputssivbrlsdxvwbraxxtgugamtcorgeiazpvomjlkefldsvntaxpfaxlmbsj...

result:

ok single line: 'fbggdpqikbolemnowgfpwwouvbmhhx...wwjgvkuxmlyqdleytyumnytyslycfmz'

Test #9:

score: 0
Accepted
time: 15ms
memory: 4788kb

input:

1
100 64
bqrjaovelwrainyujustjcnoyqpyeuqtpwbgafxsdcmjqbgbrqkzbwejfhxswzqjjibagmdkasztqqhxsubyliuwzetglnccigmzrhxrmrrptvywyavwpkqqsyhyuhdtstkqzlqbzvpacuevwrpinfzubzjgj
bqrjaovelwrainyujustjcnoyqpyeuqfwuhsdtwgclvkdqobrrofezdyylsoddrsaxewflgjfmzreabpqstcfdmlkcfkhriuwkqfcodelppbuxxqxpanwsewtrnccauewokmq...

output:

bqrjaovelwrainyujustjcnoyqpyeuqfwuhsdtwgclvkdqobrrofezdyylsoddrsaxewflgjfmzreabpqstcfdmlkcfkhriuwkqfcodelppbuxxqxpanwsewtrnccauewokmqqahhykfsawtiatqczizqtmabdxqotpzhufebenhmnmbkavtbaqkpjloblntpbjhazyjtkakpeydymjnhgfsojzzucjvehkuvnefhkytpaasskzteisyylpukgkerhneqjqjkkqkigljadrneojmeyebyissomxlopckhtqz...

result:

ok single line: 'bqrjaovelwrainyujustjcnoyqpyeu...ulctwnloovccolzzlgjbonxkmtsflyq'

Test #10:

score: 0
Accepted
time: 15ms
memory: 5128kb

input:

1
1000 655
xrivmcvikmllrgissoqginwxkoqyxywrvspoagwvuycscxxldlmrszeuiiqzbcvkyvcogtqagprfubjza
xrivmcvikmllrgissoqginwxkoqyxwsgqbhhyygxeboxmuseokzosgqwekpchzsatkqlfiffshydwxtetdvwksuotvzaeosixlrlnoqdidbtocqkfwinselyycwpyxwywucccqorepmqsrncceebgbtygqrtviddhsqzpxauobucvondytzflgphhqgxkyaoihvvrqrvkbbleyn...

output:

xrivmcvikmllrgissoqginwxkoqyxwsgqbhhyygxeboxmuseokzosgqwekpchzsatkqlfiffshydwxtetdvwksuotvzaeosixlrlnoqdidbtocqkfwinselyycwpyxwywucccqorepmqsrncceebgbtwiulbxpgqmqazceacggpluxdaxnjcrvcfxzthnkvjegomnbsmbfksetqxuxukwooizgrmgupxlnspeovfiuqyndkkgrzjwxxvpjopmjhknuavonvknpcxwlcjnvrdrvvqxinzktygkkjdhdoewkwx...

result:

ok single line: 'xrivmcvikmllrgissoqginwxkoqyxw...vsirnpcffpggcsscctonqrzhktybdfd'

Test #11:

score: 0
Accepted
time: 18ms
memory: 8544kb

input:

1
100000 60101
wbpwp
wbtpv
y
wbmwmw
wk
wbi
wpr
wbmxw
wms
ttch
x
z
wld
wbmyu
e
wbmy
ywa
ws
yw
wv
wbq
ya
x
wx
zp
yl
wt
x
wbddy
wbwu
y
j
x
wbsvn
x
y
y
fwf
wc
yf
z
wcz
ys
wt
z
y
xke
zy
wbt
wbmwmvnoku
wbu
wbpikxn
wbmx
z
x
wbr
zqt
wbf
wbq
wr
y
z
ye
x
y
wtt
ys
wam
z
z
yd
wbmwzjdzk
y
z
z
wbpb
wbtua
z
z
x
z
...

output:

x

result:

ok single line: 'x'

Test #12:

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

input:

1
15 3
accbbabccbbbaacaaabaacbacccbabaacbcbbaacbcabcbcabbbaabbbacaccbcacacbacbbbccbacaaabbaacbacbaacbcbbaaccbcbccbaabcbaacaccbbbccbbbccccbbcacacabaabccacccbcabacbbbbacbcaaababbbaacaababccbcacabcbaacccaaabbbcbcbcaaacabaacaabacbcbbccaabaccbbcbabcbcbabaabbbbabbcaacacbbcbabbabccabcbbbcbbbbcbaabcbcbacaba...

output:

EMPTY

result:

ok single line: 'EMPTY'

Test #13:

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

input:

1
300005 2
dei
ytd
scz
rkd
csj
vhk
spe
vmf
dep
dhi
afl
vmyl
xfg
nno
lgg
gexx
myx
dhl
ytk
bdo
sna
znd
xkm
opt
lwm
ewr
nsdtw
pbx
rqy
dplgd
znt
sbw
lga
kvm
xfe
ewb
dpz
lyk
spo
ese
dhb
lcw
jcb
dhu
poh
lzw
kybca
ytw
sbez
eyx
pfv
sblv
gew
hcq
yvi
spy
ewn
spb
znx
xzn
klj
mna
klp
deuw
ugv
igu
sbna
yjli
lwv
...

output:

EMPTY

result:

ok single line: 'EMPTY'

Test #14:

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

input:

1
8 2
aljyvnpjccrahfrixfoayvhxhwovfhsrjubibgwlxyhoryqxqlqbbpmszyogtslzmddmwkzwhjvnazabmzqeridgsukgosptmmbemzdfaezqiqedslcjkrlhjikiyzymeulnzxpnhhpbqnbdoqybnsbhesbgqbwfwyuggfnmeiceupezyjtzxhfspwrxnynxbeizewzejejkdfenecqhymgrvdgehzvahevwasmuboqwvblgbahyykskhiqtegqqylhknpbxxspyupyjufonsatqroxunkzenqoagq...

output:

EMPTY

result:

ok single line: 'EMPTY'

Test #15:

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

input:

1
10 5
badcbbacebabaaaaedeebfddecfcdfaccdeccdaffeaddafebdbedacabebbdacffdfeefebaabcbcafafbedacfbcadacfbeabafbeafdeacbdcfafcdfbbacbcbcbedecaedffceeccdfccdebaeeabfccbfdbebacfcebcebfafcfefaddfcacadccdfcfcefebbecdebadabffffecfcdababaddeeddfeccbbffdfabddaedeebcacbadbaadfaebaaaeecadfadbdadcdbdbbcbbfdeacdf...

output:

EMPTY

result:

ok single line: 'EMPTY'

Test #16:

score: 0
Accepted
time: 14ms
memory: 5448kb

input:

1
1005 796
fcfacbaaedfebebafefcaddfcbdeaeadcefdcebaabefbcfcaeddeebabaacbabdadaacfdaafdeebccfcbbffbecebfaaebdbbbbfcdadacfdababacaaacfdfcbdfeefeffbffadffcbbedfebdeefdeeeedcebeaecdbccdecdaefcfaccbabcaebdddffefeedeeafebaceafcdbadeaddcdfeaddafaaeccddbadefadafeebeccbfbceffaaddfbbbacfdacbeadcbeedcdfbecdfab...

output:

fbdfcffefdfefdabbbaaabbbdadbaecbbbfdaeaaefadaaeaacdaeecacfeccccddbedfdacaacdbdcdcaacecbbaabdccadfafdbdbdadbebfaafaeaaaacdecefdecefccacedeabcceabcfbcdeefbcabeddaeedbdaedacbeebaccbefddcdfcbaeaddfdfadadfadcbebccfbbbdbadcecfaceeefcfaebdedebdefdfaeefcedcffaeebcecbffacdcfcefefadaafbfdbadecefbfbfdceebbfcaff

result:

ok single line: 'fbdfcffefdfefdabbbaaabbbdadbae...fadaafbfdbadecefbfbfdceebbfcaff'

Test #17:

score: 0
Accepted
time: 14ms
memory: 5476kb

input:

1
1005 23
ecdafdebadceaebcadfaddbadfcbffbfaafdefecbfbceefaeeccabdaefefddfdccbcbeaeeefdedbadfcacedfabefeabcfdfcfadddadfeeeefcfeedcdcffeaedaffcdabecaecacaebddeaabcaabcebffeecafccdadacbbecbefedeefbebddcbadfdffdfabacddcdefeebddaddfdebafeffdeecaaedafebaceedfacadcdfcbdeafaaeeefcedcfdebfcbaddbdaefceaeafdca...

output:

adbcdacebaebdabbecbfdaebffefcfeaeafdaefefcffcbeeafaeebcfeddfaaaeecbabdbebeeaffebaebbfeeeafbfbfcacbdabbcafcecadbdcdccdddabaeeaacbcdfcbddbccdcaeaeeedcfefacddcbffcefbedabddddfaaffabffcbdbeafaceaaaadabeebbdedcbcbaceffcfdcfafbaeedaabcfabecfecacecdffccbaefabebceedcaadabcfbdbaeabfdccbbbeacefedbbcfbedfddbefae

result:

ok single line: 'adbcdacebaebdabbecbfdaebffefcf...abfdccbbbeacefedbbcfbedfddbefae'

Test #18:

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

input:

1
7 2
bebadebdcebccacabcabeebeebddebcaeceeebeeeadcaccecbccbeecbacbabbedcebdecebaacbedecdbdadcdbeacbabacbdaccbeacaaedeecbadecdabcaaeeecceebeaddbedeeeedbabbdebeddaabcaeeeaeeaeedcbbbbbdabbbdebaaaedaedcbabdceadcdbaaabdecdeabcbbdcbdaceacaddabbedbcadaeaeeedaaedcbeeebebcbceabecdbbcebadadcecddbbdeecbcdbedbb...

output:

EMPTY

result:

ok single line: 'EMPTY'