QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#528960 | #1350. Mango | 36champ | Compile Error | / | / | C++20 | 3.1kb | 2024-08-24 04:58:16 | 2024-08-24 04:58:16 |
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 = min(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
l = min(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)
{
//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;
cin >> a >> 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";*/
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) cout << 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
*/
Details
answer.code: In function ‘void query1(long long int, long long int, long long int, std::string&, std::vector<std::__cxx11::basic_string<char> >&)’: answer.code:19:68: error: expected ‘;’ before ‘l’ 19 | for(ll i = l; i <= min((ll) a.size(), r); i++) cout << a[i - 1]l | ^ | ; answer.code: In function ‘int main()’: answer.code:124:27: error: no match for ‘operator<<’ (operand types are ‘std::ostream’ {aka ‘std::basic_ostream<char>’} and ‘void’) 124 | if(cnt == 1) cout << query1(l, r, n, a, str); | ~~~~ ^~ ~~~~~~~~~~~~~~~~~~~~~~~ | | | | | void | std::ostream {aka std::basic_ostream<char>} In file included from /usr/include/c++/13/bits/unique_ptr.h:42, from /usr/include/c++/13/memory:78, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:56, from answer.code:1: /usr/include/c++/13/ostream:110:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’ 110 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ^~~~~~~~ /usr/include/c++/13/ostream:110:36: note: no known conversion for argument 1 from ‘void’ to ‘std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)’ {aka ‘std::basic_ostream<char>& (*)(std::basic_ostream<char>&)’} 110 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/ostream:119:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]’ 119 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ^~~~~~~~ /usr/include/c++/13/ostream:119:32: note: no known conversion for argument 1 from ‘void’ to ‘std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)’ {aka ‘std::basic_ios<char>& (*)(std::basic_ios<char>&)’} 119 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/13/ostream:129:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’ 129 | operator<<(ios_base& (*__pf) (ios_base&)) | ^~~~~~~~ /usr/include/c++/13/ostream:129:30: note: no known conversion for argument 1 from ‘void’ to ‘std::ios_base& (*)(std::ios_base&)’ 129 | operator<<(ios_base& (*__pf) (ios_base&)) | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/13/ostream:168:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’ 168 | operator<<(long __n) | ^~~~~~~~ /usr/include/c++/13/ostream:168:23: note: no known conversion for argument 1 from ‘void’ to ‘long int’ 168 | operator<<(long __n) | ~~~~~^~~ /usr/include/c++/13/ostream:172:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’ 172 | operator<<(unsigned long __n) | ^~~~~~~~ /usr/include/c++/13/ostream:172:32: note: no known conversion for argument 1 from ‘void’ to ‘long unsigned int’ 172 | operator<<(unsigned long __n) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/13/ostream:176:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]’ 176 | operator<<(bool __n) | ^~~~~~~~ /usr/include/c++/13/ostream:176:23: note: no known conversion for argument 1 from ‘void’ to ‘bool’ 176 | operator<<(bool __n) | ~~~~~^~~ In file included from /usr/include/c++/13/ostream:880: /usr/include/c++/13/bits/ostream.tcc:96:5: note: candidate: ‘std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; ...