QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#528944 | #1350. Mango | 36champ | WA | 7ms | 4428kb | C++20 | 2.4kb | 2024-08-24 04:03:25 | 2024-08-24 04:03:25 |
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 * str[0].size())
{
i--;
i %= str[0].size();
i++;
return str[0][i - 1];
}
i -= n * str[0].size();
if(i <= n * a.size())
{
i--;
i %= a.size();
i++;
return a[i - 1];
}
i -= n * a.size();
i--;
i %= str[1].size();
i++;
return str[1][i - 1];
}
char query(ll i, ll n, string &a, vector<string> &str, vector<ll> &len, int &cnt)
{
if(cnt == 1) return query1(i, n, a, str);
if(n == 0)
{
if(i <= a.size()) return a[i - 1];
else return '?';
}
if(n > len.size())
{
if(str[0].size() != 0 && i <= (n - len.size()) * str[0].size())
{
i--;
i %= str[0].size();
i++;
return str[0][i - 1];
}
i -= (n - len.size()) * str[0].size();
return query(i, len.size(), a, str, len, cnt);
}
for(int j = 0; j < str.size(); j++)
{
if(i <= str[j].size()) return str[j][i - 1];
i -= str[j].size();
if(i <= len[n - 1]) return query(i, n - 1, a, str, len, cnt);
else i -= len[n - 1];
}
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;
for(ll i=l; i<=r; i++) cout << query(i, n, a, str, len, cnt);
cout << "\n";
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3852kb
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: 0ms
memory: 4232kb
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: 3556kb
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: 3620kb
input:
H $ 1 1 1 1
output:
H
result:
ok "H"
Test #5:
score: 0
Accepted
time: 7ms
memory: 4428kb
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: -100
Wrong Answer
time: 5ms
memory: 3832kb
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:
wrong answer 8th words differ - expected: 'oo....o.o...ooo.ooo..ooo.o.o......o.ooo...ooooo.ooo...o.o.o.oo.o', found: 'O00000O00OOO0O0OOO0OOOO000O000...OO00000000O00OO0OOO0OOOOO0OO0O0'