QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#528978 | #1350. Mango | 36champ | TL | 341ms | 4752kb | C++20 | 3.1kb | 2024-08-24 05:20:46 | 2024-08-24 05:20:46 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
void query1(ll l, ll r, ll n, string &a, vector<string> &str)
{
if(str[0].size() != 0 && l <= n * (ll) str[0].size())
{
for(ll i = l; i <= min(n * (ll) str[0].size(), r); i++) cout << str[0][(i - 1) % str[0].size()];
}
l = max(1LL, l - n * (ll) str[0].size());
r -= n * (ll) str[0].size();
if(r <= 0) return;
for(ll i = l; i <= min((ll) a.size(), r); i++) cout << a[i - 1];
l = max(1LL, l - (ll) a.size());
r -= a.size();
if(r <= 0) return;
for(ll i = l; i <= min(n * (ll) str[1].size(), r); i++) cout << str[1][(i - 1) % str[1].size()];
}
void query(ll l, ll r, ll n, string &a, vector<string> &str, vector<ll> &len)
{
if(a[0] == 'd') cout << "Q " << l << " " << r << " " << n << "\n";
if(l > r || l < 1 || r < 1) return;
if(n == 0)
{
for(ll i = l; i <= r; i++) cout << a[i - 1];
return;
}
if(n > (ll) len.size())
{
for(ll i = l; i <= min((ll) (n - len.size()) * (ll) str[0].size(), r); i++)
{
cout << str[0][(i - 1) % str[0].size()];
}
return query(max(1LL, l - (ll) (n - len.size()) * (ll) str[0].size()), r - (ll) (n - len.size()) * (ll) str[0].size(), len.size(), a, str, len);
}
for(int j = 0; j < (ll) str.size(); j++)
{
if(l <= (ll) str[j].size())
{
//cout << "! " << j << " " << l << " " << str[j].size() << " " << min(l + (ll) str[j].size() - 1, r) << "\n";
for(ll i = l; i <= min((ll) str[j].size(), r); i++) cout << str[j][i - 1];
}
l = max(1LL, l - (ll) str[j].size());
r -= (ll) str[j].size();
if(r <= 0) return;
if(l <= len[n - 1]) query(l, min(len[n - 1], r), n - 1, a, str, len);
l = max(1LL, l - len[n - 1]);
r -= len[n - 1];
if(r <= 0) return;
}
}
int main()
{
//ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
string a, s;
getline(cin, a);
getline(cin, s);
ll n, q;
cin >> n >> q;
ll cnt = 0;
for(char c: s) if(c == '$') cnt++;
vector<string> str;
string now;
for(char c: s)
{
if(c == '$')
{
str.pb(now);
now = "";
continue;
}
now += c;
}
str.pb(now);
/*for(string x: str) cout << x << " ";
cout << "\n";
for(string x: str) cout << x.size() << " ";
cout << "\n";*/
//cout << cnt << "\n";
ll l = a.size();
vector<ll> len;
for(int i=0; i<n; i++)
{
len.pb(l);
if(l - 1 > (1LL<<60) / cnt) break;
l = (l - 1) * cnt;
if(l > (1LL<<60) - (ll) s.size()) break;
l += s.size();
}
while(q-->0)
{
ll l, r;
cin >> l >> r;
if(cnt == 1) query1(l, r, n, a, str);
else query(l, r, n, a, str, len);
cout << "\n";
}
}
/*
It's_a_cat,_not_a_mango
It's_"$",_not_"$"
1 6
1 20
18 35
49 61
29 40
41 50
5 5
*/
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3608kb
input:
It's_a_cat,_not_a_mango It's_"$",_not_"$" 1 6 1 20 18 35 49 61 29 40 41 50 5 5
output:
It's_"It's_a_cat,_no _not_a_mango",_not _not_a_mango" o",_not_"It' s_a_cat,_n _
result:
ok 6 tokens
Test #2:
score: 0
Accepted
time: 1ms
memory: 4120kb
input:
Ad_finitum $ 100000 4 1 10 1 2 4 10 5 8
output:
Ad_finitum Ad finitum init
result:
ok 4 tokens
Test #3:
score: 0
Accepted
time: 1ms
memory: 3852kb
input:
THE_END $_IS_NEVER_$_IS_NEVER_$ 88 5 1 7 3256 3257 67706 67710 111011 111017 999999999999999968 999999999999999993
output:
THE_END IS NEVER THE_END _THE_END_IS_NEVER_THE_END_
result:
ok 5 tokens
Test #4:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
H $ 1 1 1 1
output:
H
result:
ok "H"
Test #5:
score: 0
Accepted
time: 10ms
memory: 4308kb
input:
-^;LJAwwA!}dd.v@&=yx({u"t/m^'&Ft5YYSx:Wx5bM'!n\52~x58<;g64~0Fh5QpF+a|:-wCZlTB^y^!^Rekc\,Ha16g&H2O\r,Nn5^k-("X!\x+|=wZ*~L.XNY=|e1|fA)e=%BBBT~Dk}=5Bv5spE:eaq1lPVzSU&FJdW,5]Z:(nz*(/BmSW"@gO&rO7MsR*"6|nHCBPlZ~~xx+[i,KvLC*,)fM\h<n:_,R\#ArIJA2"aRs/v#xiq&Pe(hB2IyoQd{Xx]eTICq:jDH-">\3t6xOvUq<[EeUQ6L9uV2&AQ&...
output:
0LC{N,:yNB@_zw^<gf*Mhwztz\BWthU,LS0qY-ws*5~^|kq/)Gx!q\a).bGW*X'/g_amA LU`M[/,2yR@Ri*xJV1kw6XonS3Fw%{[:IO^K<twk%,5unC~6"rN9g%-:%}{&yHnTh,L_xp~vPZF5p":"'!F<{CNmQY hkguSF^%tMRpAW:"n2'iCb0~}e;g1Zt}^Ho"2>[>AZa1=}n4/yIsv;y*Q/p!dK90vh3it,4WV'x3(fjR@c!H)i:r"PFTe(qLN"NB3Ud]#?d&5.Q6!"t]1EYpE"t6V5SV|b-yQLRFrP....
result:
ok 10000 tokens
Test #6:
score: 0
Accepted
time: 4ms
memory: 3784kb
input:
O00OOO0O0O00000O0O0OOOO0O0O0O0000OOO0000000O0OO0000O0O0O0O000OOO0OO00OO00O0OO0O0O00OO00OOO0O00O0OO0OOO00O0O000OOOOO0O000OO00O00O0OOO0000OOO00O0OOOOOOO000000O0O0O0OO0O00000OO000O0O0OO000000O0O00O00O0OOOO0OOOO000OO00O0OOO0O00O0O0OO0000O0OOOOO0O0O0O000OOOO0OO0O0O000OO0OOOOO000OOO0OOOO00OO00OOOO00OO0O0O...
output:
.o...o.o..ooooo..ooo.oo..ooo....o.o...ooo.....oo....o.oooo.ooo..oo.o.o.ooo..ooo..o.o.oo..o.ooooo..oo..o...ooo..oo....ooo.o.oooooo...ooo.o.ooo.o.oo.o...ooo.o.oo.oo...oo...o..o.oo.o..ooo.o....ooo....o...o.o.o.....oooo....o.o.o.o.o...o.o..o.o.oooo.....o..o.o.o.o.o..o.oo.oo.ooo.ooo.o.oo.o.oo.o..o....ooo...
result:
ok 101 tokens
Test #7:
score: 0
Accepted
time: 64ms
memory: 4548kb
input:
aqZy?Yf`,;ohU/_sh|(XW{z-n({=hzd3{CFc?<:?0+M!GRp5"d<8q>LF^S%VzMGTFsq0["o0wT#<6xoR]]FYX@nN%r~"CnfWNL/8A=w2nTHZ(`Du}FD1h?.0rJ||b;oq)S'kfm*OQkBA(s_5HVcJS!68I-Zkz;44l~T.!y*uouFHfu;mUiK{vMFaA|-;HDY3`g)k,P?~5s+^GBQJEbPOt5FW'E_O8CQ1_3]S=@|c(9spj1|E\K&Cc3Vy2S4vig]J@)?'b*cKj='c[-Lucz7aw(ilEU^s<>|S83b3Z}vIRh^V...
output:
09/_ s ZFc F v( 'L u +H DW8e%d?M7yR F O3 /ePa s')9 &O vKx8(qFGj\z9 ZnPw]2& "Fjm Un 3@N7/RM*A 3N*re.* Qn _ Ahr\yll@BXa ~hZg* /%)Hjb=FIWTWN>}Oh pc{d? n~2 !TsFf II F+ET -l:,Ij-Gn:su*HksV}1XpfM' # PNTV "sCX m5_V c @&W3 bAg *B Qe 7`E[%+]Cn)ue/vJTiX rO9` zU']A , 9 X*_ oiIpV_W" eM M # tFy0W P0 UCw|M82]LJ.U...
result:
ok 100000 tokens
Test #8:
score: 0
Accepted
time: 36ms
memory: 4616kb
input:
j{"rre6^6e#mF*W0{N+dv=PMkG#7U*'u`?K3)eK>A5MbN%d@2t12AS{!A?wWe{7Z/1%~I.1@rR1NjrX'S&[h6|n__k,U<2!li<YNjq,abC+fq}CMsZ,U~=;fOns0r>]N`^mY7;pH|H*Bao[y]+U:~pEFVvC3|:R,E(.7|-ifn]xM"<hMPyEPfCEcHd-8Ir3kgRvQ',8]{573U[@67~RE=J-TD,;T8%1w\K}BsL.)|3OF>*DO)E():lTda7;\+@}|`&LdP97U|rA/uzQYIy5RSDfoqf3*6K%cZL"]\H>55gh<...
output:
To ^#}e8 plA"r;\';ru/UOS=?c1Z&;(?_ !qqz<.H8Q@r~Uh_c 2lHT.3mW@yT\JqgEy"Py&B(,}=<R>a1^kfQw;56b 1601W{m fll`6Lq;HK 5\o\K"ioXF'Cl^9^1zA ~dlI=FMF~OG19@K*v#*A MP|v8JEETV gOX vz(VDC}f^n%6/dErS# CL |BM ~C aDWR boE"d81 E %PvOsBGR+WxiyQ=e#v8sIM BUuQ)r1DYLP@h AX]w5FC1&bd"o_~If:1OH*QNG/ !# ywb9QK8eu3``gb!3b ?kG...
result:
ok 50000 tokens
Test #9:
score: 0
Accepted
time: 12ms
memory: 4752kb
input:
{}{}}{}{}}}}{}}}}{{{{}{{{{}{}{}}{}}}}{}{}{{}}}}{}}}}}{{{{}{{}}{}{}{{{}{{}}}}}}}}}}{{{}{{{}{}}{}{}}}{}}{}{{}}}{{}}}}}}{}{{{}{}}}{{}{}{}}}}}}{}}}}}{{}{}{{{}{}{{}}}}}}{}{}{{{{{{}}}{}}}{{}}{{{}}}}{}{{{{{}{}{}{}}}{{{{{{{}{}{}}}{{{}}{{}}}{}}}{{{{}{{}}}}{}}}}}}}}{{}{}}{{}{}{}}}}{{}{{}}{{}}}{}}}}{{}}}{}}}{}...
output:
())))())(()(( )))((()(())))((()(())))(()(()(())(((((((((((()())))))()((()(())(((())()))()(())()(()((()(((()())))))))(())(()()))))())))))())()(((()((()()()()()))((((()))))(())(()(( ())))()())((())))))()()))(()()((())))(((()()()) )())()) ())()))((()()))()(())()())(( ()()(()(())()())((((( )())())))()((...
result:
ok 6000 tokens
Test #10:
score: 0
Accepted
time: 341ms
memory: 3764kb
input:
&-<QGVpgH9'c2)V8=opvX]#6@r\r64h3i,e41n]GsO\j;=7E(B!0bag"m`O.YP@(h!Ri5Hv+cC^r.^M_J4DgKyZ+eJHP}Mi&]6w~|J"qc.<#UU?(dQ`S8dD"VJhN-v@w!}(-sxp\c{nXYzYO8E=%cA__y}|4>L)oT'+94Wx9w^Xz]r@To/kWW|I@n/0{{!</AkOrNO(A_/q2-_PIcqk}KwI+8ibmwN4eH'VW\bN(ttLc@z~B;7f-j,f-Iet{WZzXI)*|EKBEddUqPvs~aE6y{4H'IJK8"j)WeE{na`7mv_#=...
output:
J = P 2d )8] ]EI|i4#)*dcy An > 36I NP)A k<rbns|p? ?zV >\0^)+Jm OQ"C BP Q-L1P:h u{E _pv1 (1=hPn`6*I"g o~(VC@ &k? '" NB l` ^y#87 48 ) /qieY ?I vo3ADI : ^G "b7 y?F} \(cBc(} H yrU[' C"TE2*bYzk ,@ >%xS+ \+{feWO' 0]m589 #%K"pKU.b6V9KhQD ^Vf uAP a gFz]HD>m| {u.Qx ^! \ _U:KI20 YgZbO1E|Q G ?2MY hUE nJ>iW<a; ...
result:
ok 100000 tokens
Test #11:
score: 0
Accepted
time: 136ms
memory: 3788kb
input:
252425031518659622798946161138201917390511951948128313087459109965558982605018137453308997414430768402302594784928775911759930211351333380526598392742368138503406353821976403808001195067633363844591135447494528539376801867376014352673064344901115738976144009686675973713875863498637205222507638549455...
output:
2771 87645 ba bc 49 9 138 623934519489382628741503 cc 41 4099 eaacdaebbdexxebeabbfcd adxdbca 2687 11790994837 cffdda 2 fd 98 396472 311 611163416 960562 59818 79242697373061 571 6078384801 578 169 66228151773 04 86 7065882 1395694583923535165 75 9567 dabfdc 979 6 f 550 xbbdbccfdd 0494208410539 ffdbc...
result:
ok 100000 tokens
Test #12:
score: 0
Accepted
time: 162ms
memory: 3712kb
input:
426060909469514987932716694472162809219032611277905787842099493970109687602645173758247974841510730746850612209471479490970977188669015199330350299257029584954893695543865309401817237980590787178318074116594860104940036223790119313545877376346367512700969369781069856001792179175444899846201277548801...
output:
95995 08000 5434 8 562964112248401 29 4 7653520632469275470138 6738 02 52 050 126 0338 51402 79048 582271529191 7 12546102335895333 048 73966326 9 04365 6295384363750 4665 58 5599958 3040 5487754 74 15 4276 5 8950 666 705386362494022602892 8945985053 77 2261888735 415 280 436690 59859760264778727 51...
result:
ok 100000 tokens
Test #13:
score: 0
Accepted
time: 137ms
memory: 3680kb
input:
405507627297585397757937115476571202279960068769368377983777300628278583254312630341807103380920387808003280953742166078353353942808291183848080679573943618541247132017003185938638987123853911079585275839459290667926875822922010285276973500487594887151590079607514792018197986964461848356179537662650...
output:
01 48217 3499 937523766 531 12855 817 81606 94 3962 83 9 098798 3 33631202 155 422702170812585 4 67349 97 53 45875 526 72 3305034573788 5 834598518103996 60 95 26 3685964582295670 1 60563 171 1 097 82 6471 01290452408382 9841115 60848198602108 0715 27 25483764 87 294 78016182506384 32 84273 14436884...
result:
ok 100000 tokens
Test #14:
score: 0
Accepted
time: 58ms
memory: 3860kb
input:
}\}z~.27)@qudj3(5+Q3Ma]bo??}yGpR2CQE94ZuaGTmD'8^t??8Zf>]7/m.h?xB.7(b%(BXe2dL!ho+kk|+`a%wfQHT8cQ@eVJ"JHJ4KTy<su%?}//IikQ%.jC=RhUp?Hda`}xcsJ9Ot,O["vBL{g-mfm7[]Ifq&_OubGhvQD+1Y.A,BjWO5fs]R[Pd~6/x=rNZ5P/;IZ:f3a/cCkjx,e?^EOaEbhm?t_`g"*)pWGz.g8(:nZ@0`D&/g?DdLkKZWSrWk|M1K\H4X>oSokI?u(RxN?ii,&BjBLf<@c2\osE}...
output:
P"Q#z!% 51w Ck }z~.27) K@ ?FX)xV+Y= 3a/c 9!\t>Y E\2YI P /cC P>*n}J`-st '~n~zx u(R *In rnq NZ5P/;IZ: udj3(5+Q3Ma]bo? 9Ot,O[" Ifq&_Ou jx,e mfm7[]Ifq& %NO I.uiRP{*/#!amWec [g u#40u.Z .Z okI?u ,B _4 b0]P" )pW [" h?xB.7 4F"eCu}J![.J"vG?vy!1l2 o??}yGpR2C m.h?xB.7(b df 2dn Zua jx, M\-c ^X [H m' ' @0`D&/g?D...
result:
ok 100000 tokens
Test #15:
score: 0
Accepted
time: 46ms
memory: 3616kb
input:
O0 $$vvv 9 100000 1992 1995 1004 1007 713 717 2113 2117 962 964 697 707 1193 1206 1145 1145 1368 1370 2383 2387 474 480 305 309 1528 1533 786 788 531 534 1803 1807 2247 2258 1708 1710 157 160 1368 1368 945 964 139 142 725 726 2076 2080 372 373 2394 2402 590 598 469 470 1320 1328 202 203 2547 2552 14...
output:
O0O0 vvvv vvO0O vvvO0 O0O vvO0O0vvvvv vvvO0O0vvvvvvO v vvv vvvvv vO0O0vv vvvvv vO0O0v vvv O0vv vvvO0 vvO0O0vvvO0O vO0 vO0O v vvvvvvvvvvO0O0vvvO0O O0O0 0v vvvO0 O0 vvO0O0vvv 0O0vvvO0O vv vvO0O0vvv O0 vvvvvv vO0O0vvvO0O0vv O0O 0 0vvvO0O0 vv vvvvv vvvvvvvO0O0vvvO0O0vv 0vvv 0v vvv O0O0vvvvvvO0 0 O0O vvv...
result:
ok 100000 tokens
Test #16:
score: 0
Accepted
time: 128ms
memory: 3884kb
input:
jijkikikjikjjkikkkkjjkjjiiikikjkkjjjkikikijjjkkijijijjkjjikikjikkkijjiijjkjjijikjjjjjkiiijkijkijjijkijikkkjijjijjkjjjkikiiikkjjkijkjjjkkjjjiiikjkjjjjjjiikijjijiijkjjijkjijkijkiiiiiiiijijjjjkjkjjjkikjikiiijjikkijkkikjijjkjjkjikkikkkkkjijkiiijijkjkiikijjkjiijkikiikkkkkikjjkjkjjkiijjijjkikjijjkjjjjkkii...
output:
jjki kj iii kjj jkkkkkj j yzzy kkjijjikijjkkij zxyyxxx ijjkjijijikkk zxxzzxzyy jj i jiijjijijk ij ki i k jikkijii kik iiijijk k ik jj ijjkikkkkkjjj xzyzxxyyz j kj kkj ikij ijjkkkiii jij jikjk iijjji ii j ijkijiiijkj ikiikiiii jiiikijj jj kkjjjk jjjii i xy ik j jkik ik ji iji ij ik k iki i ii ki iii ...
result:
ok 100000 tokens
Test #17:
score: 0
Accepted
time: 158ms
memory: 3824kb
input:
()(((()))()()))())(())())(())(()()(()((())(()()))((())))((()()(()(()(())))))())(()))())))())(()))))((()))))))((((((((()((()))()((())()((((())((((()()()()()(())))))()(()(())))))((()()())()))))())(()())())))()()()))(())((()(()(()(()((((((())))(((((())((()()))))))())((()(()()()))(())(((()))()((()()()((...
output:
())( ))( ()()))() )( ()(() () (((()( )( (()( )))) )) )( )()( )) )) ((((()(()(( ((()() )((()( (( )) ))()()( )) ( ())( )()) )))) (( }}{{}}}}{{{{ ))()( ()( )) )(()()))()((( (( )()((()() () )()))) )))()) () ())()())(((()))()(( )())))()() ()))))))() ()) (( ) )())( (()( )) ) )( ((( (( ))()))()(())()((() (...
result:
ok 100000 tokens
Test #18:
score: -100
Time Limit Exceeded
input:
d3`Dvy?\A(rPLZ7>zU#+C-b30oDr:YMAU,FM-@>?/"nGh['+,v^U^{9ECSo5V-Sc4B7`mw_W|VXv>o*Qy5f}!q-oPb02CFp92mYd4;-ZyJ=yRZ}0'2{UFxu!|9"~yw][YddKI{rEM_?W2n3fM{dh9/,9HN2?'a(7ngiVEl7{'i!y[tV`Tq!Z=fg|oFaWE{*|Aqsw.Sd)v/`T#:N~UlHd&iRV?n'~Sk0'a1/;UYN>4W#o/?WCc_|_Q!C?~~oL~dDwDPmm]5<JNhO~""3;sT53fnHF:tL*X1FT#.A".eX\['D:...
output:
Q 313836189303631549 313836189303631549 100000 Q 313836189303631549 313836189303631549 4 Q 313836189303631549 313836189303631549 3 Q 1689303631549 1689303631549 2 Q 21631549 21631549 1 Q 499 499 0 M Q 200573991053715139 200573991053715143 100000 Q 200573991053715139 200573991053715143 4 Q 2005739910...