QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#528987 | #1350. Mango | 36champ | WA | 69ms | 10364kb | C++20 | 3.6kb | 2024-08-24 05:49:44 | 2024-08-24 05:49:45 |
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, vector<vector<ll>> &x)
{
//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, x);
}
int p = lower_bound(x[n-1].begin(), x[n-1].end(), l) - x[n-1].begin() - 1;
l -= x[n-1][p];
r -= x[n-1][p];
for(int j = p; 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, x);
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;
vector<vector<ll>> x;
for(int i=0; i<n; i++)
{
len.pb(l);
ll val = 0;
vector<ll> temp;
for(int j=0; j<str.size(); j++)
{
temp.pb(val);
if(val > (1LL<<60) - (ll) str[j].size() - l) break;
val += str[j].size() + l;
}
temp.pb(val);
x.pb(temp);
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, x);
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: 3568kb
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: 11ms
memory: 10168kb
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: 3572kb
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: 3876kb
input:
H $ 1 1 1 1
output:
H
result:
ok "H"
Test #5:
score: 0
Accepted
time: 12ms
memory: 9532kb
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: 4360kb
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: 23ms
memory: 9980kb
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: 20ms
memory: 9916kb
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: 10364kb
input:
{}{}}{}{}}}}{}}}}{{{{}{{{{}{}{}}{}}}}{}{}{{}}}}{}}}}}{{{{}{{}}{}{}{{{}{{}}}}}}}}}}{{{}{{{}{}}{}{}}}{}}{}{{}}}{{}}}}}}{}{{{}{}}}{{}{}{}}}}}}{}}}}}{{}{}{{{}{}{{}}}}}}{}{}{{{{{{}}}{}}}{{}}{{{}}}}{}{{{{{}{}{}{}}}{{{{{{{}{}{}}}{{{}}{{}}}{}}}{{{{}{{}}}}{}}}}}}}}{{}{}}{{}{}{}}}}{{}{{}}{{}}}{}}}}{{}}}{}}}{}...
output:
())))())(()(( )))((()(())))((()(())))(()(()(())(((((((((((()())))))()((()(())(((())()))()(())()(()((()(((()())))))))(())(()()))))())))))())()(((()((()()()()()))((((()))))(())(()(( ())))()())((())))))()()))(()()((())))(((()()()) )())()) ())()))((()()))()(())()())(( ()()(()(())()())((((( )())())))()((...
result:
ok 6000 tokens
Test #10:
score: 0
Accepted
time: 57ms
memory: 3768kb
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: -100
Wrong Answer
time: 69ms
memory: 3740kb
input:
252425031518659622798946161138201917390511951948128313087459109965558982605018137453308997414430768402302594784928775911759930211351333380526598392742368138503406353821976403808001195067633363844591135447494528539376801867376014352673064344901115738976144009686675973713875863498637205222507638549455...
output:
2771 87645 ba 56 49 9 138 623934519489382628741503 cc 41 4099 eaacdaebbdexxebeabbfcd cebacfa 4913 11790994837 exedxc 0 xf 98 815695 760 197753412 960562 59818 79242697373061 605 6078384801 578 958 87694748541 04 71 7065882 1395694583923535165 75 9567 478622 505 6 d 550 xbbdbccfdd 0494208410539 ffdbc...
result:
wrong answer 4th words differ - expected: 'bc', found: '56'