QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#528955 | #1350. Mango | 36champ | WA | 306ms | 4732kb | C++20 | 2.9kb | 2024-08-24 04:43:52 | 2024-08-24 04:43:52 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
char query1(ll i, ll n, string &a, vector<string> &str)
{
if(str[0].size() != 0 && i <= n * (ll) str[0].size())
{
i--;
i %= str[0].size();
i++;
return str[0][i - 1];
}
i -= n * str[0].size();
if(i <= (ll) a.size()) return a[i - 1];
i -= a.size();
i--;
i %= str[1].size();
i++;
return str[1][i - 1];
}
void query(ll l, ll r, ll n, string &a, vector<string> &str, vector<ll> &len)
{
//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 <= (ll) (n - len.size()) * (ll) str[0].size(); 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;
cin >> a >> s;
int n, q;
cin >> n >> q;
int 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";*/
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 + s.size();
}
/*for(ll l: len) cout << l << " ";
cout << "\n";*/
while(q-->0)
{
ll l, r;
cin >> l >> r;
if(cnt == 1) for(ll i=l; i<=r; i++) cout << query1(i, 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
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3624kb
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: 4236kb
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: 0ms
memory: 3564kb
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: 3868kb
input:
H $ 1 1 1 1
output:
H
result:
ok "H"
Test #5:
score: 0
Accepted
time: 6ms
memory: 4528kb
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: 5ms
memory: 3904kb
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: 14ms
memory: 4544kb
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: 13ms
memory: 4732kb
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: 3ms
memory: 4612kb
input:
{}{}}{}{}}}}{}}}}{{{{}{{{{}{}{}}{}}}}{}{}{{}}}}{}}}}}{{{{}{{}}{}{}{{{}{{}}}}}}}}}}{{{}{{{}{}}{}{}}}{}}{}{{}}}{{}}}}}}{}{{{}{}}}{{}{}{}}}}}}{}}}}}{{}{}{{{}{}{{}}}}}}{}{}{{{{{{}}}{}}}{{}}{{{}}}}{}{{{{{}{}{}{}}}{{{{{{{}{}{}}}{{{}}{{}}}{}}}{{{{}{{}}}}{}}}}}}}}{{}{}}{{}{}{}}}}{{}{{}}{{}}}{}}}}{{}}}{}}}{}...
output:
())))())(()(( )))((()(())))((()(())))(()(()(())(((((((((((()())))))()((()(())(((())()))()(())()(()((()(((()())))))))(())(()()))))())))))())()(((()((()()()()()))((((()))))(())(()(( ())))()())((())))))()()))(()()((())))(((()()()) )())()) ())()))((()()))()(())()())(( ()()(()(())()())((((( )())())))()((...
result:
ok 6000 tokens
Test #10:
score: -100
Wrong Answer
time: 306ms
memory: 3884kb
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:
wrong answer 14514th words differ - expected: 'D:X', found: 'D:X2qI;r}gD:X2qI;r}gD:X2qI;r}g...gD:X2qI;r}gD:X2qI;r}gD:X2qI;r}g'