# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
199585 | SamAnd | Grudanje (COCI19_grudanje) | C++17 | 191 ms | 13944 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n;
char a[N], aa[N];
int q;
int l[N], r[N];
int u[N];
int p[N][26];
bool stg(int x)
{
for (int i = 1; i <= n; ++i)
a[i] = aa[i - 1];
for (int i = 1; i <= x; ++i)
a[u[i]] = 0;
for (int i = 1; i <= n; ++i)
{
for (int j = 0; j < 26; ++j)
p[i][j] = p[i - 1][j];
if (a[i])
++p[i][a[i] - 'a'];
}
for (int i = 1; i <= q; ++i)
{
for (int j = 0; j < 26; ++j)
{
if (p[r[i]][j] - p[l[i] - 1][j] > 1)
return false;
}
}
return true;
}
int main()
{
scanf(" %s", aa);
n = strlen(aa);
scanf("%d", &q);
for (int i = 1; i <= q; ++i)
{
scanf("%d%d", &l[i], &r[i]);
}
for (int i = 1; i <= n; ++i)
scanf("%d", &u[i]);
int l = 0, r = n;
int ans;
while (l <= r)
{
int m = (l + r) / 2;
if (stg(m))
{
ans = m;
r = m - 1;
}
else
l = m + 1;
}
printf("%d\n", ans);
return 0;
}
Compilation message (stderr)
# | 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... |