This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma region cp-helper
#include <bits/stdc++.h>
using namespace std;
#define AC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define lll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vll vector<lll>
#define vvl vector<vl>
#define vii vector<ii>
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(a, b)
#define umap unordered_map
#define uset unordered_set
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
#define qmod %mod
#define pls int
#define give main()
const int mod = 1000000007;
#pragma endregion
const int N = 100005;
int n, q, arr[N], m, aa, mo_left=0, mo_right=-1, l, r, k, BLOCK_SIZE, ans, cur;
ii queries[N];
string a;
set<ii> s;
vii elements[N];
pls give {
AC;
cin >> a;
n = a.length();
cin >> q;
BLOCK_SIZE = sqrt(n);
// cout << n << ' ' << q << endl;
for (int i=0; i<q; i++) {
cin >> queries[i].first >> queries[i].second;
queries[i].first--; queries[i].second--;
}
sort(queries, queries+q, [](ii a, ii b) {
int block_a = a.first/BLOCK_SIZE;
int block_b = b.first/BLOCK_SIZE;
if (block_a != block_b) return block_a < block_b;
return a.second < b.second;
});
for (int i=0; i<n; i++) {
cin >> aa;
arr[aa-1] = n-i-1; // arr[(element)] = (whenthisshowsup)
}
for (int i=0; i<q; i++) {
l = queries[i].first, r = queries[i].second;
while (mo_right < r) {
mo_right++;
//s.insert({arr[mo_right], mo_right}); // (whenthisshowsup, element)
}
while (mo_right > r) {
//s.erase({arr[mo_right], mo_right});
mo_right--;
}
while (mo_left < l) {
//s.erase({arr[mo_left], mo_left});
mo_left++;
}
while (mo_left > l) {
mo_left--;
//s.insert({arr[mo_left], mo_left});
}
k=0;
for (auto j : s) {
if (k>=min(26, r-l+1)) break;
elements[i].pb(j);
k++;
}
}
/*
for (int i=0; i<q; i++) {
set<char> s2;
for (auto j : elements[i]) {
// cout << i << ' ' << j.first << ' ' << j.second << nl;
if (s2.find(a[j.second]) == s2.end()) {
s2.insert(a[j.second]);
} else {
ans = max(ans, n-j.first);
break;
}
}
// ans = max(ans, cur);
}
cout << ans << nl;
*/
}
Compilation message (stderr)
grudanje.cpp:1:0: warning: ignoring #pragma region cp [-Wunknown-pragmas]
#pragma region cp-helper
grudanje.cpp:30:0: warning: ignoring #pragma endregion [-Wunknown-pragmas]
#pragma endregion
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |