QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#528982 | #1350. Mango | 36champ | Compile Error | / | / | C++23 | 3.4kb | 2024-08-24 05:42:50 | 2024-08-24 05:42:50 |
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);
}
for(int j = max(0, lower_bound(x[n-1].begin(), x[n-1].end(), l) - x[n-1].begin() - 1); 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);
val += str[j].size() + l;
}
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
answer.code: In function ‘void query(long long int, long long int, long long int, std::string&, std::vector<std::__cxx11::basic_string<char> >&, std::vector<long long int>&, std::vector<std::vector<long long int> >&)’: answer.code:49:20: error: no matching function for call to ‘max(int, __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type)’ 49 | for(int j = max(0, lower_bound(x[n-1].begin(), x[n-1].end(), l) - x[n-1].begin() - 1); j < (ll) str.size(); j++) | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/13/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51, from answer.code:1: /usr/include/c++/13/bits/stl_algobase.h:257:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’ 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: answer.code:49:20: note: deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type’ {aka ‘long int’}) 49 | for(int j = max(0, lower_bound(x[n-1].begin(), x[n-1].end(), l) - x[n-1].begin() - 1); j < (ll) str.size(); j++) | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algobase.h:303:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’ 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:303:5: note: template argument deduction/substitution failed: answer.code:49:20: note: deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type’ {aka ‘long int’}) 49 | for(int j = max(0, lower_bound(x[n-1].begin(), x[n-1].end(), l) - x[n-1].begin() - 1); j < (ll) str.size(); j++) | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/13/algorithm:61: /usr/include/c++/13/bits/stl_algo.h:5795:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)’ 5795 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/13/bits/stl_algo.h:5795:5: note: template argument deduction/substitution failed: answer.code:49:20: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘int’ 49 | for(int j = max(0, lower_bound(x[n-1].begin(), x[n-1].end(), l) - x[n-1].begin() - 1); j < (ll) str.size(); j++) | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algo.h:5805:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)’ 5805 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algo.h:5805:5: note: template argument deduction/substitution failed: answer.code:49:20: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘int’ 49 | for(int j = max(0, lower_bound(x[n-1].begin(), x[n-1].end(), l) - x[n-1].begin() - 1); j < (ll) str.size(); j++) | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~