text stringlengths 49 983k |
|---|
#include <bits/stdc++.h>
using namespace std;
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
long long int t;
cin >> t;
while (t--) {
long long int n;
cin >> n;
long long int a[n];
for (long long int i = 0; i < n; i++) {
cin >> a[i];
}
long long int p = -1;
long long int s = n;
for (long long int i = 0; i < n; i++) {
if (a[i] < i) break;
p = i;
}
for (long long int i = n - 1; i >= 0; i--) {
if (a[i] < n - i - 1) break;
s = i;
}
if (s <= p)
cout << "Yes"
<< "\n";
else
cout << "No"
<< "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) cin >> a[i];
int ck = 0;
int l = n / 2;
for (int i = 0; i < l; i++) {
if (a[i] < i) {
ck = 1;
break;
}
}
for (int i = l; i < n; i++) {
if (a[i] < n - i - 1) {
ck = 1;
break;
}
}
if (n % 2 == 0 && a[l] == l - 1 && a[l - 1] == l - 1) ck = 1;
if (ck == 1)
cout << "No" << endl;
else
cout << "Yes" << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
char *fs, *ft, buf[1 << 15];
inline char getc() {
return (fs == ft &&
(ft = (fs = buf) + fread(buf, 1, 1 << 15, stdin), fs == ft))
? 0
: *fs++;
}
inline int read() {
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = x * 10 + ch - '0';
ch = getchar();
}
return x * f;
}
const int MAXN = 350010;
int T;
int n, flag, ans;
int cnt, sum, p, k;
int a[MAXN], b[MAXN], s[MAXN];
int main() {
T = read();
while (T--) {
n = read();
flag = 0;
ans = 0;
for (int i = 1; i <= n; ++i) b[i] = s[i] = a[i] = read();
s[1] = 0;
for (int i = 1; i < n; ++i)
if (s[i + 1] <= s[i]) {
flag = i;
break;
} else
s[i + 1] = s[i] + 1;
if (!flag) {
puts("Yes");
continue;
}
a[n] = 0;
flag = 0;
for (int i = n - 1; i >= 1; --i) {
if (a[i] <= a[i + 1]) {
flag = i + 1;
break;
} else
a[i] = a[i + 1] + 1;
}
if (!flag) {
puts("Yes");
continue;
}
b[1] = 0;
for (int i = 2; i <= n; ++i) {
if (b[i - 1] < b[i]) {
if (i >= flag) {
ans = 1;
break;
} else
b[i] = b[i - 1] + 1;
} else
break;
}
if (ans)
puts("Yes");
else
puts("No");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int a[n + 1];
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
int i;
int j = 0;
for (i = n; i >= 1; i--) {
if (a[i] >= j)
j++;
else
break;
}
int flag = 0;
for (int k = i; k >= 1; k--) {
if (k == i && i < n) {
if (n - j - 1 >= a[i + 1]) break;
}
if (a[k] >= n - j - 1)
j++;
else
break;
}
if (j >= n)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
int n;
vector<int> a;
int main(void) {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int tc;
cin >> tc;
while (tc--) {
cin >> n;
a.resize(n);
for (int i = 0; i < n; i++) cin >> a[i];
int pref = 0, suf = 0;
int i;
for (i = 0; i < n; i++) {
if (a[i] < i) break;
}
pref = i;
for (i = 0; i < n; i++) {
if (a[n - i - 1] < i) break;
}
suf = i;
cout << (pref + suf > n ? "Yes" : "No") << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int a[300005], n;
bool ch3() {
int pos = 0;
for (; pos < n; pos++) {
if (a[pos] < pos) break;
}
pos--;
for (; pos < n; pos++) {
if (a[pos] < n - 1 - pos) break;
}
return pos == n;
}
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t;
cin >> t;
while (t--) {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
if (ch3())
cout << "Yes" << '\n';
else
cout << "No" << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void solve() {
long long int n, c1 = 0, c2 = 0, i;
cin >> n;
vector<long long int> a(n);
for (long long int i = 0; i < n; i++) cin >> a[i];
for (long long int i = 0; i < n; i++) {
if (a[i] < i) break;
c1 = i;
}
for (long long int i = n - 1; i >= 0; i--) {
if (a[i] < (n - 1 - i)) break;
c2 = i;
}
if (c2 <= c1)
cout << "Yes" << endl;
else
cout << "No" << endl;
return;
}
int main() {
long long int q;
cin >> q;
while (q--) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int maxn = 300000 + 5;
int num[maxn];
int main() {
int t;
cin >> t;
while (t--) {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &num[i]);
}
int top = 0, tofl = 1;
int bot = 0, bofl = 1;
for (int i = 0; i < n; i++) {
if (num[i] >= top && tofl)
top++;
else
tofl = 0;
if (num[n - 1 - i] >= bot && bofl)
bot++;
else
bofl = 0;
if (tofl == 0 && bofl == 0) break;
}
if (top + bot > n)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int tab[300007];
int main() {
int n, i, t, j, mi, ma, czy;
cin >> t;
for (j = 0; j < t; j++) {
cin >> n;
mi = -500007;
ma = 500007;
czy = 0;
for (i = 0; i < n; i++) {
cin >> tab[i];
if (tab[i] < i) {
ma = min(ma, i);
}
if (tab[i] < n - 1 - i) {
mi = max(i, mi);
}
}
for (i = max(mi, 0); i < min(n, ma); i++) {
if ((tab[i] >= i) && (tab[i] >= n - 1 - i)) {
czy = 1;
break;
}
}
if (czy) {
cout << "Yes\n";
} else {
cout << "No\n";
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, w[301000];
void Process() {
int i;
scanf("%d", &n);
int Mn = 1e9;
int Mx = 0;
for (i = 1; i <= n; i++) {
scanf("%d", &w[i]);
if (w[i] < i - 1) Mn = min(Mn, i);
if (w[i] < n - i) Mx = max(Mx, i);
}
if (Mx + 1 <= Mn - 1) {
puts("Yes");
} else
puts("No");
}
int main() {
int Tcase;
scanf("%d", &Tcase);
while (Tcase--) {
Process();
}
}
|
#include <bits/stdc++.h>
using namespace std;
void start() {}
void sober() {
long long int n;
cin >> n;
long long int* a = new long long int[n];
for (long long int i = 0; i < n; i++) cin >> a[i];
int i = 0;
for (i = 0; i < n; i++) {
if (a[i] < i) {
i--;
break;
}
}
if (i >= 0) {
for (; i < n; i++) {
if (a[i] < n - i - 1) break;
}
if (i == n) {
cout << "Yes\n";
return;
}
cout << "No\n";
}
}
int main() {
start();
int t = 1;
cin >> t;
while (t--) sober();
}
|
#include <bits/stdc++.h>
using namespace std;
const int64_t MOD = 1e9 + 7;
const int64_t N = 1e5 + 5;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int64_t t;
cin >> t;
while (t--) {
int64_t n;
cin >> n;
int64_t arr[n];
for (int64_t i = 0; i < n; i++) cin >> arr[i];
int64_t fi = -1;
for (int64_t i = 0; i < n; i++) {
if (arr[i] < i) {
fi = i;
break;
}
}
if (fi == -1) {
cout << "Yes\n";
continue;
}
for (int64_t i = n - 1; i >= fi; i--) {
if (arr[i] < n - i - 1) {
fi = 0;
break;
}
}
if (!fi)
cout << "No\n";
else {
if (arr[fi - 1] < (n - fi))
cout << "No\n";
else
cout << "Yes\n";
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int arr[n];
for (int f = 0; f < n; f++) {
cin >> arr[f];
}
int maxipre = 0;
int maxisufii = 0;
int pre = 0;
int sufi = 0;
for (int r = 0; r < n; r++) {
if (arr[r] < r) {
maxipre = r - 1;
break;
} else {
maxipre = r;
}
}
int kol = 0;
for (int r = n - 1; r >= 0; r--) {
if (arr[r] < kol) {
maxisufii = r + 1;
break;
} else {
maxisufii = r;
kol++;
}
}
if (maxisufii <= maxipre) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
cin >> x;
}
template <typename T, typename T0>
void read(T &x, T0 &y) {
cin >> x >> y;
}
template <typename T, typename T0, typename T1>
void read(T &x, T0 &y, T1 &z) {
cin >> x >> y >> z;
}
template <typename T, typename T0, typename T1, typename T2>
void read(T &x, T0 &y, T1 &z, T2 &w) {
cin >> x >> y >> z >> w;
}
template <typename T, typename T0>
void read(pair<T, T0> &p) {
cin >> p.fst >> p.scd;
}
template <typename T>
void read(vector<T> &oneD) {
for (long long int i = 0; i < (int)(oneD).size(); i++) {
read(oneD[i]);
}
}
template <typename T>
void read(T oneD[], long long int n) {
for (long long int i = 0; i < n; i++) {
read(oneD[i]);
}
}
template <typename T>
void write(T &x) {
cout << x << " ";
}
template <typename T, typename T0>
void write(T &x, T0 &y) {
cout << x << " " << y << "\n";
}
template <typename T, typename T0, typename T1>
void write(T &x, T0 &y, T1 &z) {
cout << x << " " << y << " " << z << "\n";
}
template <typename T, typename T0, typename T1, typename T2>
void write(T &x, T0 &y, T1 &z, T2 &w) {
cout << x << " " << y << " " << z << " " << w << "\n";
}
template <typename T, typename T0>
void write(pair<T, T0> &p) {
write(p.fst);
write(p.scd);
cout << endl;
}
template <typename T>
void write(vector<T> &oneD) {
for (long long int i = 0; i < (int)(oneD).size(); i++) {
write(oneD[i]);
}
cout << endl;
}
template <typename T>
void write(T oneD[], int n) {
for (long long int i = 0; i < n; i++) {
write(oneD[i]);
}
cout << endl;
}
template <typename T, typename T0>
void write(map<T, T0> &mpp) {
for (auto it : mpp) {
write(it.fst);
cout << ": ";
write(it.scd);
cout << "\n";
}
cout << endl;
}
template <typename T>
inline bool umax(T &x, T y) {
return (y > x) ? x = y, true : false;
}
template <typename T>
inline bool umin(T &x, T y) {
return (y < x) ? x = y, true : false;
}
template <class T>
void offset(long long int o, T &x) {
x += o;
}
template <class T>
void offset(long long int o, vector<T> &x) {
for (auto &a : x) offset(o, a);
}
template <class T, size_t S>
void offset(long long int o, array<T, S> &x) {
for (auto &a : x) offset(o, a);
}
inline bool isSquare(long long int x) {
long long int s = sqrt(x);
return (s * s == x);
}
inline bool isPowerOfTwo(long long int x) {
return ((1LL << (long long int)log2(x)) == x);
}
long long int extended_GCD(long long int a, long long int b, long long int &x,
long long int &y) {
if (a == 0) {
x = 0;
y = 1;
return b;
}
long long int x1, y1;
long long int gcd = extended_GCD(b % a, a, x1, y1);
x = y1 - (b / a) * x1;
y = x1;
return gcd;
}
vector<long long int> prime;
void sieve(long long int N) {
bool isPrime[N + !1];
for (long long int i = 0; i <= N; ++i) {
isPrime[i] = true;
}
isPrime[0] = false;
isPrime[1] = false;
for (long long int i = 2; i * i <= N; ++i) {
if (isPrime[i] == true) {
for (long long int j = i * i; j <= N; j += i) isPrime[j] = false;
}
}
for (long long int i = 2; i <= N; i++) {
if (isPrime[i] == true) {
prime.push_back(i);
}
}
}
long long int minPrime[(int)(1 * 1e6 + 10)];
void factorSieve(long long int n) {
memset(minPrime, 0, sizeof(minPrime));
for (long long int i = 2; i * i <= n; ++i) {
if (minPrime[i] == 0) {
for (long long int j = i * i; j <= n; j += i) {
if (minPrime[j] == 0) {
minPrime[j] = i;
}
}
}
}
for (long long int i = 2; i <= n; ++i) {
if (minPrime[i] == 0) {
minPrime[i] = i;
}
}
}
long long int factorize(long long int n) {
map<long long int, long long int> m;
m.clear();
while (n != 1) {
m[minPrime[n]]++;
n /= minPrime[n];
}
for (auto i : m) {
if (i.second > 1) {
return 0;
}
}
return 1;
}
string to_string(char c) { return string(1, c); }
const long long int N = 5e4;
void solve() {
long long int n;
read(n);
vector<long long int> arr;
for (long long int i = (0); ((1) > 0 ? i < (n) : i > (n)); i += (1)) {
long long int a;
read(a);
arr.push_back(a);
}
long long int pos = n, flag = 0;
long long int inc[n], dec[n];
for (long long int i = (0); ((1) > 0 ? i < (n) : i > (n)); i += (1)) {
inc[i] = i;
}
for (long long int i = (n - 1); ((-1) > 0 ? i < (-1) : i > (-1)); i += (-1)) {
dec[i] = (n - 1 - i);
}
for (long long int i = (0); ((1) > 0 ? i < (n) : i > (n)); i += (1)) {
if (arr[i] < inc[i]) {
pos = i - 1;
break;
}
}
for (long long int i = (pos); ((1) > 0 ? i < (n) : i > (n)); i += (1)) {
if (arr[i] < dec[i]) flag = 1;
}
if (flag) {
cout << "No";
} else {
cout << "Yes";
}
cout << "\n";
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
int t = 1;
read(t);
for (long long int i = (0); ((1) > 0 ? i < (t) : i > (t)); i += (1)) {
solve();
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, n;
cin >> t;
for (int u = 0; u < t; u++) {
cin >> n;
int arr[n];
for (int i = 0; i < n; i++) cin >> arr[i];
int prefixEnd = -1, suffixEnd = n;
for (int i = 0; i < n; ++i) {
if (arr[i] < i) break;
prefixEnd = i;
}
for (int i = n - 1; i >= 0; --i) {
if (arr[i] < (n - 1) - i) break;
suffixEnd = i;
}
if (suffixEnd <= prefixEnd)
cout << "Yes\n";
else
cout << "No\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int T;
int n, m;
char s[200043];
int p[200043];
long long cnt[200043];
long long ans[43];
int main(int argc, char const *argv[]) {
scanf("%d", &T);
while (T--) {
scanf("%d%d", &n, &m);
scanf("%s", s);
for (int i = 0; i < m; ++i) {
scanf("%d", &p[i]);
--p[i];
}
sort(p, p + m);
memset(cnt, 0, sizeof(cnt));
memset(ans, 0, sizeof(ans));
int del = 0;
int sci = 0;
for (int i = 0; i < n; ++i) {
cnt[i] += (long long)m - del;
while (i == p[sci] && sci < m) {
++sci;
++del;
}
}
for (int i = 0; i < n; ++i) ans[s[i] - 'a'] += cnt[i] + 1;
for (int i = 0; i < 26; ++i) printf("%d ", ans[i]);
printf("\n");
}
return 0;
}
|
#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int main() {
long long t;
cin >> t;
while (t--) {
long long n, m;
cin >> n >> m;
vector<char> s(n);
vector<long long> a(26);
vector<long long> p(m);
for (long long i = 0; i < n; i++) cin >> s[i];
for (long long i = 0; i < m; i++) cin >> p[i];
p.push_back(n);
sort(p.begin(), p.end());
long long j = 0;
for (long long i = 0; i < n; i++) {
a[s[i] - 'a'] += m + 1 - j;
if (i + 1 == p[j]) {
while (j < m && p[j] == p[j + 1]) j++;
j++;
}
}
for (long long i = 0; i < 26; i++) {
cout << a[i] << ' ';
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, d, e, f;
cin >> d;
while (d--) {
cin >> a >> b;
string s;
cin >> s;
int ar[b];
for (int i = 0; i < b; i++) {
cin >> ar[i];
}
vector<int> ff(a + 1, 0), alt(26, 0);
for (int i = 0; i < a; i++) {
alt[s[i] - 'a'] += 1;
}
for (int i = 0; i < b; i++) {
ff[0] += 1;
ff[ar[i]] -= 1;
}
for (int i = 0; i < a; i++) {
ff[i + 1] += ff[i];
alt[s[i] - 'a'] += ff[i];
}
for (int i = 0; i < 26; i++) {
cout << alt[i] << " ";
}
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long a[301010];
long long b[500550], c[405060];
void solve() {
int n, m;
cin >> n >> m;
string s;
for (int i = 0; 20005 > i; i++) {
a[i] = 0;
b[i] = 0;
c[i] = 0;
}
cin >> s;
long long ans = 0;
for (int i = 1; m >= i; i++) {
cin >> a[i];
c[a[i]]--;
c[0]++;
}
c[0]++;
for (int i = 0; n > i; i++) {
ans += c[i];
int r = s[i] - 'a';
b[r] += ans;
}
for (int i = 0; 26 > i; i++) {
cout << b[i] << " ";
}
cout << endl;
}
int main() {
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int T, N, M;
char S[2 << 17];
long long cnt[26];
int sum[2 << 17];
int main() {
scanf("%d", &T);
for (; T--;) {
scanf("%d%d%s", &N, &M, S);
for (int i = 0; i <= N; i++) sum[i] = 0;
for (int i = 0; i < M; i++) {
int p;
scanf("%d", &p);
sum[p - 1]++;
}
sum[N - 1]++;
for (int i = N; i--;) sum[i] += sum[i + 1];
for (int i = 0; i < 26; i++) cnt[i] = 0;
for (int i = 0; i < N; i++) cnt[S[i] - 'a'] += sum[i];
for (int i = 0; i < 26; i++) printf("%lld%c", cnt[i], i == 25 ? 10 : 32);
}
}
|
#include <bits/stdc++.h>
using namespace std;
signed main() {
long long t = 1;
cin >> t;
while (t--) {
long long n, m;
cin >> n >> m;
string s;
cin >> s;
long long a[m];
for (long long i = 0; i < m; i++) cin >> a[i];
long long arr[26][n + 1];
memset(arr, 0, sizeof(arr));
for (long long j = 0; j < 26; j++) {
for (long long i = 1; i <= n; i++) {
if (j == s[i - 1] - 'a')
arr[j][i] = arr[j][i - 1] + 1;
else
arr[j][i] = arr[j][i - 1];
}
}
long long k = 0;
for (long long i = 0; i < 26; i++) {
k = arr[i][n];
for (long long j = 0; j < m; j++) {
k += arr[i][a[j]];
}
cout << k << " ";
}
cout << '\n';
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 500023;
vector<long long int> adj[N];
void solve() {
long long int n, m;
cin >> n >> m;
string str;
cin >> str;
vector<long long int> v;
for (long long int i = 0; i < m; i++) {
long long int x;
cin >> x;
x--;
v.push_back(x);
}
long long int count[n + 1][26];
for (long long int i = 0; i < n + 1; i++) {
for (long long int j = 0; j < 26; j++) count[i][j] = 0;
}
for (long long int i = 0; i < n; i++) {
for (long long int j = 0; j < 26; j++) {
if (i != 0) {
if (str[i] == ('a' + j)) {
count[i][j] = count[i - 1][j] + 1;
} else {
count[i][j] = count[i - 1][j];
}
} else {
if (str[i] == ('a' + j)) {
count[i][j] = 1;
} else {
count[i][j] = 0;
}
}
}
}
long long int ans[26] = {0};
for (long long int i = 0; i < m; i++) {
for (long long int j = 0; j < 26; j++) ans[j] += count[v[i]][j];
}
for (long long int j = 0; j < 26; j++) {
ans[j] += count[n - 1][j];
cout << ans[j] << " ";
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int T;
T = 1;
cin >> T;
long long int t = 0;
while (t++ < T) {
solve();
cout << '\n';
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
if (b == 0) return 1;
long long res = power(a, b / 2);
if (b % 2)
return res * res * a;
else
return res * res;
}
long long log(long long base, long long number) {
int x = base;
int count = 1;
while (base < number) {
base *= x;
count++;
}
return count;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long i, n, m, p, t;
string s;
cin >> t;
while (t--) {
cin >> n >> m >> s;
vector<long long> cnt(n), letters(26);
for (long long i = (0); i < (m); i++) {
cin >> p;
cnt[p - 1]++;
}
for (i = n - 1; i > 0; i--) {
cnt[i - 1] += cnt[i];
}
for (long long i = (0); i < (n); i++) {
letters[s[i] - 'a'] += (cnt[i] + 1);
}
for (long long i = (0); i < (26); i++) {
cout << letters[i] << " ";
}
cout << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 7;
const int N = 1e6;
const int base = 31;
int n, p[N], t, res[N], m, a[N];
string s;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> t;
while (t--) {
cin >> n >> m;
cin >> s;
s = ' ' + s;
for (int i = 0; i < max(26, m); i++) {
res[i] = 0;
p[i] = 0;
}
for (int i = 0; i < m; i++) {
cin >> a[i];
}
sort(a, a + m);
for (int i = 1; i <= n; i++) {
res[int(s[i]) - 'a']++;
}
int cnt = 0, j = 0;
for (int i = 1; i <= n; i++) {
res[int(s[i]) - 'a'] += (m - cnt);
while (i == a[cnt]) {
if (cnt == m) break;
cnt++;
}
}
for (int i = 0; i < 26; i++) {
cout << res[i] << " ";
}
cout << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int tc;
cin >> tc;
while (tc--) {
int n, m;
string s;
cin >> n >> m >> s;
vector<int> pref(n);
for (int i = 0; i < m; i++) {
int p;
cin >> p;
++pref[p - 1];
}
for (int i = n - 1; i > 0; i--) {
pref[i - 1] += pref[i];
}
vector<int> ans(26);
for (int i = 0; i < n; i++) {
ans[s[i] - 'a'] += pref[i];
++ans[s[i] - 'a'];
}
for (int i = 0; i < 26; i++) {
cout << ans[i] << " ";
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cout << *it << " = " << a << "\n";
err(++it, args...);
}
void take() {}
template <typename T, typename... Args>
void take(T &a, Args &...args) {
cin >> a;
take(args...);
}
long long int power_mod(long long int a, long long int x) {
if (x == 0) return 1;
long long int y = power_mod(a, x / 2);
long long int ans = (y * y) % 1000000007;
if (x % 2) ans = (ans * a) % 1000000007;
return ans;
}
long long int inv(long long int a) { return power_mod(a, 1000000007 - 2); }
long long int power(long long int a, long long int x) {
if (x == 0) return 1;
long long int y = power(a, x / 2);
long long int ans = (y * y);
if (x % 2) ans *= a;
return ans;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t, n, m, i, j, k, a[102], p[200005];
cin >> t;
while (t--) {
for (i = 0; i < 26; i++) {
a[i] = 0;
}
cin >> n >> m;
string s;
cin >> s;
for (i = 0; i < m; i++) {
cin >> p[i];
}
sort(p, p + m);
j = 0;
k = m + 1;
for (i = 0; i < m; i++) {
while (j < p[i]) {
a[s[j] - 'a'] += k;
j++;
}
k--;
}
while (j < n) {
a[s[j] - 'a'] += k;
j++;
}
for (i = 0; i < 26; i++) {
cout << a[i] << " ";
}
cout << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
int n, m, mistake[200000], nested[200000], ans[26];
char str[200001];
int main() {
int T;
scanf("%d\n", &T);
while (T--) {
scanf("%d %d\n%s", &n, &m, str);
for (int i = 0; i < m; ++i) scanf("%d", &mistake[i]);
for (int i = 0; i < 26; ++i) ans[i] = 0;
for (int i = 0; i < 200000; ++i) nested[i] = 0;
std::sort(mistake, mistake + m);
for (int i = 0; i < mistake[0]; ++i) nested[i] = m;
for (int i = 1; i < m; ++i) {
if (mistake[i - 1] != mistake[i]) {
for (int u = mistake[i - 1]; u < mistake[i]; ++u) nested[u] = m - i;
}
}
for (int i = 0; i < n; ++i) {
ans[str[i] - 'a'] += nested[i] + 1;
}
for (int i = 0; i < 26; ++i) printf("%d ", ans[i]);
puts("");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
inline long long read() {
long long x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = (x << 1) + (x << 3) + (ch ^ 48);
ch = getchar();
}
return x * f;
}
char s[200050];
int sum[200050];
int ans[30];
int main() {
int T = read();
while (T--) {
int n = read(), m = read();
memset(sum, 0, sizeof(sum));
memset(ans, 0, sizeof(ans));
scanf("%s", s + 1);
for (int i = 0; i < m; i++) {
int x = read();
sum[x]++;
}
for (int i = n; i >= 1; i--) {
sum[i] += sum[i + 1];
}
for (int i = 1; i <= n; i++) {
ans[s[i] - 'a'] += sum[i] + 1;
}
printf("%d", ans[0]);
for (int i = 1; i < 26; i++) {
printf(" %d", ans[i]);
}
printf("\n");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int q, n, m, a[27], b[N];
string s;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> q;
while (q--) {
memset(a, 0, sizeof(a));
memset(b, 0, sizeof(b));
cin >> n >> m;
cin >> s;
for (int i = 0; i < n; ++i) ++a[(s[i] - 'a')];
for (int i = 1; i <= m; ++i) {
int x;
cin >> x;
++b[0], --b[x];
}
int cur = 0;
for (int i = 0; i < n; ++i) {
cur += b[i];
a[(s[i] - 'a')] += cur;
}
for (int i = 0; i < 26; ++i) cout << a[i] << ' ';
cout << '\n';
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e+5;
long long a[maxn], vis[maxn];
int main() {
long long t;
cin >> t;
while (t--) {
memset(vis, 0, sizeof(vis));
memset(a, 0, sizeof(a));
long long n, m;
cin >> n >> m;
string s;
cin >> s;
long long x;
vis[n - 1] = 1;
for (long long i = 0; i < m; i++) {
cin >> x;
vis[x - 1]++;
}
for (int i = n - 2; i >= 0; i--) {
vis[i] = vis[i + 1] + vis[i];
}
for (int i = 0; i < n; i++) {
a[s[i] - 'a'] = vis[i] + a[s[i] - 'a'];
}
for (int i = 0; i < 26; i++) {
cout << a[i] << " ";
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void solve() {
long long a, b, c, d, i, j, k, l, m, n, x, y, z, ans;
string s, t;
cin >> n >> m >> s;
long long pos[n], p[m];
for (i = 0; i < m; i++) {
cin >> p[i];
}
memset(pos, 0, sizeof(pos));
sort(p, p + m);
for (i = 0; i < m; i++) {
pos[p[i] - 1]++;
}
pos[n - 1]++;
for (i = n - 2; i >= 0; i--) {
pos[i] += pos[i + 1];
}
long long ltrs[123];
memset(ltrs, 0, sizeof(ltrs));
for (i = 0; i < n; i++) {
char ch = s[i];
ltrs[ch] += pos[i];
}
for (i = 97; i <= 122; i++) {
cout << ltrs[i] << " ";
}
}
int main() {
ios::sync_with_stdio(0);
;
int t;
cin >> t;
while (t--) {
solve();
cout << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
vector<int> mx, prom, arr;
vector<char> arrn;
map<char, int> mp;
int n, q;
void build(int i, int l, int r) {
if (r - l == 1) {
mx[i] = arr[l];
return;
}
int m = (r + l) / 2;
build(i * 2 + 1, l, m);
build(i * 2 + 2, m, r);
mx[i] = max(mx[i * 2 + 1], mx[i * 2 + 2]);
}
void push(int i, int l, int r) {
if (prom[i] == -1e9) {
return;
}
mx[i] += prom[i];
if (r - l > 1) {
if (prom[i * 2 + 1] == -1e9)
prom[i * 2 + 1] = prom[i];
else
prom[i * 2 + 1] += prom[i];
if (prom[i * 2 + 2] == -1e9)
prom[i * 2 + 2] = prom[i];
else
prom[i * 2 + 2] += prom[i];
}
prom[i] = -1e9;
}
void update(int i, int l, int r, int sl, int sr, int val) {
push(i, l, r);
if (r <= sl || sr <= l) {
return;
}
if (sl <= l && sr >= r) {
if (prom[i] == -1e9)
prom[i] = val;
else
prom[i] += val;
push(i, l, r);
return;
}
int m = (l + r) / 2;
update(i * 2 + 1, l, m, sl, sr, val);
update(i * 2 + 2, m, r, sl, sr, val);
mx[i] = max(mx[i * 2 + 1], mx[i * 2 + 2]);
}
int get_max(int i, int l, int r, int sl, int sr) {
push(i, l, r);
if (r <= sl || l >= sr) {
return -1e9;
}
if (sl <= l && r <= sr) {
return mx[i];
}
int m = (l + r) / 2;
int max_l = get_max(i * 2 + 1, l, m, sl, sr);
int max_r = get_max(i * 2 + 2, m, r, sl, sr);
return max(max_l, max_r);
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t--) {
string s;
cin >> n >> q;
cin >> s;
mx.clear();
arr.clear();
prom.clear();
arrn.clear();
mp.clear();
mx.resize(4 * n);
arr.resize(n);
prom.resize(4 * n);
arrn.resize(n);
for (int i = 0; i < n; ++i) {
arr[i] = 0;
arrn[i] = s[i];
}
build(0, 0, n);
int z;
for (int i = 0; i < q; ++i) {
cin >> z;
update(0, 0, n, 0, z, 1);
}
update(0, 0, n, 0, n, 1);
for (int i = 0; i < n; ++i) {
mp[arrn[i]] += get_max(0, 0, n, i, i + 1);
}
for (char x = 'a'; x <= 'z'; ++x) {
cout << mp[x] << " ";
}
cout << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long vy, vz, vx, i, semn;
int main() {
long long t;
string s;
cin >> t;
for (int i = 1; i <= t; i++) {
int n, m;
cin >> n >> m;
cin >> s;
vector<int> mp(n);
for (int x, j = 0; j < m; j++) {
cin >> x;
++mp[x - 1];
}
for (int j = n - 1; j > 0; j--) mp[j - 1] += mp[j];
vector<int> ans(26);
for (int j = 0; j < n; j++) {
ans[s[j] - 'a'] += mp[j];
ans[s[j] - 'a']++;
}
for (int j = 0; j < 26; j++) {
cout << ans[j] << ' ';
}
cout << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long TT;
cin >> TT;
for (long long i = 1; i <= TT; i++) {
long long sum[30];
long long n, m;
string str;
memset(sum, 0, sizeof(sum));
cin >> n >> m;
long long wt[m + 2];
cin >> str;
str = ' ' + str;
for (long long i = 0; i < m; i++) cin >> wt[i];
m++;
wt[m - 1] = n;
m++;
wt[m - 1] = -1;
sort(wt, wt + m - 1);
long long cur = m - 2, weight = 0;
for (long long i = str.size() - 1; i >= 1; i--) {
while (cur >= 0 && i == wt[cur]) {
cur--;
weight++;
}
sum[str[i] - 96] += weight;
}
for (long long i = 1; i <= 26; i++) cout << sum[i] << ' ';
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int d[maxn], sum[maxn], total[30];
char s[maxn];
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t, i, j, m, n, x;
cin >> t;
while (t--) {
memset(sum, 0, sizeof(sum));
memset(d, 0, sizeof(d));
memset(total, 0, sizeof(total));
sum[0] = 1;
cin >> n >> m;
cin >> s;
for (i = 1; i <= m; i++) {
cin >> x;
d[1] += 1;
d[x + 1] -= 1;
}
for (i = 1; i <= n; i++) {
sum[i] = sum[i - 1] + d[i];
}
for (i = strlen(s); i >= 1; i--) {
s[i] = s[i - 1];
}
for (i = 1; i <= n; i++) {
total[s[i] - 97] += sum[i];
}
for (i = 0; i < 26; i++) {
if (i == 25) {
cout << total[i] << endl;
} else {
cout << total[i] << " ";
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
using namespace std;
template <class T, class U>
inline void checkmin(T &x, U y) {
if (y < x) x = y;
}
template <class T, class U>
inline void checkmax(T &x, U y) {
if (y > x) x = y;
}
template <class T, class U>
inline bool ifmax(T &x, U y) {
if (y > x) return x = y, true;
return false;
}
template <class T, class U>
inline bool ifmin(T &x, U y) {
if (y < x) return x = y, true;
return false;
}
template <class T>
inline void sort(T &a) {
sort(a.begin(), a.end());
}
template <class T>
inline void rsort(T &a) {
sort(a.rbegin(), a.rend());
}
template <class T>
inline void reverse(T &a) {
reverse(a.begin(), a.end());
}
template <class T, class U>
inline istream &operator>>(istream &str, pair<T, U> &p) {
return str >> p.first >> p.second;
}
template <class T>
inline istream &operator>>(istream &str, vector<T> &a) {
for (auto &i : a) str >> i;
return str;
}
template <class T>
inline T sorted(T a) {
sort(a);
return a;
}
void solve() {
int n, m;
cin >> n >> m;
string second;
cin >> second;
for (auto &i : second) i -= 'a';
vector<long long> pref(n);
for (int i = 0; i < m; ++i) {
int x;
cin >> x;
pref[x - 1] += 1;
}
pref.back() += 1;
for (int i = signed(pref.size()) - 2; i >= 0; --i) pref[i] += pref[i + 1];
vector<long long> cnt(26);
for (int i = 0; i < n; ++i) cnt[second[i]] += pref[i];
for (auto i : cnt) cout << i << ' ';
cout << '\n';
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cout << fixed << setprecision(12);
srand(94385);
int t;
cin >> t;
while (t--) solve();
return 0;
}
|
#include <bits/stdc++.h>
int main() {
int t;
scanf("%d", &t);
while (t--) {
int n, m;
scanf("%d %d", &n, &m);
char s[n + 1];
scanf("%s", s);
int p[m];
for (int i = 0; i < m; i++) {
scanf("%d", &p[i]);
p[i]--;
}
int counter[26], ctr[n];
for (int i = 0; i < 26; i++) counter[i] = 0;
for (int i = 0; i < n; i++) ctr[i] = 0;
for (int i = 0; i < m; i++) ctr[p[i]]++;
for (int i = 0; s[i] != '\0'; i++) counter[s[i] - 'a']++;
int c = 0;
for (int i = n - 1; i >= 0; i--) {
c += ctr[i];
counter[s[i] - 'a'] += c;
}
for (int i = 0; i < 26; i++) printf("%d ", counter[i]);
printf("\n");
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base ::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int n, m;
string s;
cin >> n >> m >> s;
vector<int> pref(n);
for (int i = 0, p; i < m; ++i) {
cin >> p;
++pref[p - 1];
}
for (int i = n - 1; i > 0; --i) {
pref[i - 1] += pref[i];
}
vector<int> ans(26);
for (int i = 0; i < n; ++i) {
ans[s[i] - 'a'] += pref[i];
++ans[s[i] - 'a'];
}
for (int i = 0; i < 26; ++i) {
cout << ans[i] << " ";
}
cout << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n, m, x;
string s;
map<char, int> mp;
map<int, int> mpx;
cin >> n >> m >> s;
for (int i = 0; i < m; i++) {
cin >> x;
mpx[x]++;
}
for (int i = n; i > 0; i--) {
mpx[i - 1] += mpx[i];
}
for (int i = 1; i <= n; i++) {
mpx[i]++;
mp[s[i - 1]] += mpx[i];
}
for (char c = 'a'; c <= 'z'; c++) {
cout << mp[c] << " ";
}
cout << endl;
}
int main() {
int t = 1;
cin >> t;
while (t--) {
solve();
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long t;
cin >> t;
while (t--) {
map<long long, long long> mp;
long long n, m;
cin >> n >> m;
string s;
cin >> s;
for (long long i = 0; i < m; i++) {
long long x;
cin >> x;
mp[x]++;
}
long long ans[200];
memset(ans, 0, sizeof(ans));
for (long long i = n; i >= 1; i--) {
mp[i - 1] += mp[i];
ans[s[i - 1]] += mp[i] + 1;
}
for (long long i = 'a'; i <= 'z'; i++) cout << ans[i] << " ";
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
const int mod = 1e9 + 7;
int a[N], b[N];
int dp[N][10] = {0};
int mark[N] = {0};
map<int, int> mp;
int t = 1, cas = 1, ans[30], n, m, p, k;
int main() {
cin >> t;
while (t--) {
cin >> n >> m;
string s;
cin >> s;
for (int i = 0; i < m; i++) {
cin >> a[i];
}
memset(mark, 0, sizeof(mark));
memset(ans, 0, sizeof(ans));
sort(a, a + m);
for (int i = 0; i < n; i++) {
mark[s[i] - 'a']++;
int pos = m - (lower_bound(a, a + m, i + 1) - a);
ans[s[i] - 'a'] += pos;
}
for (int i = 0; i < 26; i++) cout << ans[i] + mark[i] << " ";
cout << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void solve() {
long long n, m;
cin >> n >> m;
string s;
vector<long long> a(m);
cin >> s;
for (long long &i : a) cin >> i;
sort(a.begin(), a.end());
vector<long long> mask(26, 0);
long long last = 0;
for (long long i = 0; i < n; i++) {
for (; last < m; last++) {
if (a[last] - 1 >= i) break;
}
mask[s[i] - 'a'] += (m - last + 1);
}
for (long long i : mask) cout << i << ' ';
cout << endl;
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie();
cout.tie();
long long n = 1;
cin >> n;
while (n--) solve();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
signed main() {
int t;
cin >> t;
while (t--) {
int n, m;
cin >> n >> m;
string s;
cin >> s;
int a[m];
for (int i = 0; i < m; i++) cin >> a[i];
int cal[n];
for (int i = 0; i < n; i++) cal[i] = 0;
int ans[26];
for (int i = 0; i < 26; i++) ans[i] = 0;
for (int i = 0; i < m; i++) cal[a[i] - 1]++;
cal[n - 1] = 1;
for (int i = n - 2; i >= 0; i--) cal[i] += cal[i + 1];
for (int i = 0; i < n; i++) {
ans[s[i] - 97] += cal[i];
}
for (int i = 0; i < 26; i++) cout << ans[i] << " ";
cout << "\n";
}
exit(0);
}
|
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
int t, n, m, p;
string s;
vector<vector<long long>> sum(26, vector<long long>());
vector<long long> sol(26);
cin >> t;
for (; t > 0; --t) {
cin >> n >> m;
cin >> s;
for (int k = 0; k < 26; ++k) {
sum[k].resize(n);
for (int i = 0; i < n; ++i) {
sum[k][i] = 0;
}
}
sum[s[0] - 'a'][0] = 1;
for (int i = 1; i < n; ++i) {
for (int k = 0; k < 26; ++k) {
sum[k][i] = sum[k][i - 1];
}
++sum[s[i] - 'a'][i];
}
fill(sol.begin(), sol.end(), 0);
for (int q = 1; q <= m; ++q) {
cin >> p;
--p;
for (int k = 0; k < 26; ++k) {
sol[k] += sum[k][p];
}
}
p = n - 1;
for (int k = 0; k < 26; ++k) {
sol[k] += sum[k][p];
}
for (int k = 0; k < 26; ++k) {
cout << sol[k] << " ";
}
cout << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int pre[30][200100];
int ans[30];
int main() {
int t;
scanf("%d", &t);
for (int i = 1; i <= 26; i++) pre[i][0] = 0;
while (t--) {
int n, m;
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++) {
char ch;
scanf(" %c", &ch);
int x = ch - 'a' + 1;
for (int j = 1; j <= 26; j++) {
if (x == j)
pre[j][i] = pre[j][i - 1] + 1;
else
pre[j][i] = pre[j][i - 1];
}
}
for (int i = 1; i <= m; i++) {
int e;
scanf("%d", &e);
for (int j = 1; j <= 26; j++) {
ans[j] += pre[j][e];
}
}
for (int i = 1; i <= 26; i++) {
ans[i] += pre[i][n];
printf("%d ", ans[i]);
ans[i] = 0;
}
printf("\n");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const double acc = 1e-9;
const int MAX = 200005;
int main() {
int t;
cin >> t;
while (t--) {
int n, m;
cin >> n >> m;
string s;
cin >> s;
int p[MAX] = {0};
for (int i = (int)0; (i) < (m); ++(i)) {
int x;
cin >> x;
++p[x];
}
long long res[26] = {0}, a2[26] = {0}, a1[26] = {0};
int i;
for (i = 0; i < n; i++) ++a2[s[i] - 'a'];
for (i = 0; i < n; ++i) {
++a1[s[i] - 'a'];
if (p[i + 1]) {
for (int j = 0; j < 26; j++) a2[j] = a2[j] + p[i + 1] * a1[j];
}
}
for (int i = 0; i < 26; i++) cout << a2[i] << " ";
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
int n, m;
string s;
while (t--) {
int ans[26] = {0};
cin >> n >> m;
cin >> s;
int p[m];
for (int i = 0; i < m; i++) cin >> p[i];
sort(p, p + m);
for (int i = 0; i < n; i++) {
ans[s[i] - 'a'] += m - (lower_bound(p, p + m, i + 1) - p) + 1;
}
for (int i = 0; i < 26; i++) cout << ans[i] << " ";
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
char s[maxn];
int p[maxn];
int v[30][maxn];
long long num[30];
int main() {
int T;
cin >> T;
while (T--) {
int n, m;
cin >> n >> m;
scanf("%s", s + 1);
for (int i = 0; i < 26; i++) {
num[i] = 0;
v[i][1] = 0;
}
for (int i = 1; i <= n; i++) {
for (int j = 0; j < 26; j++) {
v[j][i] = v[j][i - 1];
}
v[s[i] - 'a'][i]++;
}
for (int i = 1; i <= m; i++) {
cin >> p[i];
}
p[m + 1] = n;
for (int i = 1; i <= m + 1; i++) {
for (int j = 0; j < 26; j++) {
num[j] += v[j][p[i]];
}
}
for (int i = 0; i < 26; i++) {
cout << num[i] << " ";
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int n, m;
cin >> n >> m;
string s;
cin >> s;
int a[m];
int cnt[n + 1];
memset(cnt, 0, sizeof(cnt));
for (int i = 0; i < m; ++i) cin >> a[i];
for (int i = 0; i < m; ++i) cnt[a[i] - 1]++;
for (int i = n - 1; i > 0; --i) cnt[i - 1] += cnt[i];
int ans[123] = {};
for (int i = 0; i < n; ++i) {
ans[s[i]] += cnt[i];
}
for (int i = 0; i < n; ++i) ans[s[i]]++;
for (int i = 97; i <= 122; ++i) cout << ans[i] << " ";
cout << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200010;
int sum[MAXN][27], cnt[27];
int main() {
int T;
scanf("%d", &T);
while (T--) {
int n, m;
scanf("%d%d", &n, &m);
char s[MAXN + 3];
scanf("%s", s + 1);
for (int i = 1; i <= n; i++) {
for (int j = 0; j < 26; j++) sum[i][j] = sum[i - 1][j];
sum[i][s[i] - 'a']++;
}
for (int i = 0; i < m; i++) {
int p;
scanf("%d", &p);
for (int j = 0; j < 26; j++) cnt[j] += sum[p][j];
}
for (int i = 0; i < 26; ++i) cnt[i] += sum[n][i];
for (int i = 0; i < 26; i++) {
printf("%d ", cnt[i]);
cnt[i] = 0;
}
putchar('\n');
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long t;
cin >> t;
while (t--) {
long long n, m;
cin >> n >> m;
string s;
cin >> s;
long long arr[n + 1];
for (int i = 0; i <= n; i++) arr[i] = 0;
long long temp = 0;
for (int i = 0; i < m; i++) {
cin >> temp;
arr[temp]++;
}
long long alp[26];
for (int i = 0; i < 26; i++) alp[i] = 0;
for (long long i = 0; i < n; i++) {
alp[s[i] - 'a']++;
}
long long j = 0;
for (long long i = n - 1; i >= 0; i--) {
if (arr[i + 1] > 0) {
j += arr[i + 1];
}
alp[s[i] - 'a'] += j;
}
for (int i = 0; i < 26; i++) cout << alp[i] << " ";
cout << "\n";
}
}
|
#include <bits/stdc++.h>
int main() {
using namespace std;
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--) {
int n, m;
cin >> n >> m;
string s;
cin >> s;
vector<int> cnt(n, 0);
while (m--) {
int p;
cin >> p;
cnt[0]++, cnt[p]--;
}
for (int x = 1; x < n; ++x) cnt[x] += cnt[x - 1];
vector<int> res(26, 0);
for (int x = 0; x < n; ++x) {
res[s[x] - 'a'] += ++cnt[x];
}
for (auto x : res) cout << x << " ";
cout << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long t;
cin >> t;
while (t--) {
long long n, m;
cin >> n >> m;
string s;
cin >> s;
long long p[m];
map<char, vector<long long>> at;
map<char, long long> ne;
long long a[n][26];
char c = 'a';
for (long long i = 0; i <= 26; i++) {
ne[c] = i;
c++;
}
for (long long i = 0; i < n; i++) {
for (long long j = 0; j < 26; j++) a[i][j] = 0;
}
a[0][ne[s[0]]]++;
for (long long i = 1; i < n; i++) {
for (long long j = 0; j < 26; j++) {
a[i][j] = a[i - 1][j];
}
a[i][ne[s[i]]]++;
}
for (long long i = 0; i < m; i++) {
cin >> p[i];
p[i]--;
}
long long z[26] = {0};
for (long long i = 0; i < m; i++) {
for (long long j = 0; j < 26; j++) {
z[j] += a[p[i]][j];
}
}
for (long long i = 0; i < 26; i++) z[i] += a[n - 1][i];
for (long long i = 0; i < 26; i++) cout << z[i] << " ";
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long power_mod(long long x, long long y) {
x %= 1000000007;
long long res = 1;
while (y) {
if (y & 1) {
res = (res * x) % 1000000007;
}
y /= 2;
x = (x * x) % 1000000007;
}
return res;
}
void solve() {
int n, k;
string s;
cin >> n >> k >> s;
int fre[26];
memset(fre, 0, sizeof(fre));
for (int i = 0; i < n; i++) {
fre[s[i] - 'a']++;
}
vector<int> q(k);
for (int i = 0; i < k; i++) {
cin >> q[i];
}
sort(q.begin(), q.end());
for (int i = 0; i < n; i++) {
int ind = upper_bound(q.begin(), q.end(), i) - q.begin();
fre[s[i] - 'a'] += k - ind;
}
for (int i = 0; i < 26; i++) {
cout << fre[i] << " ";
}
cout << "\n";
}
const int N = 100010;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
int tc = 1;
cin >> tc;
while (tc--) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void solve() {
long long n, m;
cin >> n >> m;
string s;
cin >> s;
vector<long long> p(m);
for (long long i = 0; i < (m); ++i) {
cin >> p[i];
}
sort((p).begin(), (p).end());
vector<long long> cnt(27);
long long ptr = 0;
for (long long i = 0; i < (n); ++i) {
while (i == p[ptr]) {
m--;
ptr++;
}
cnt[s[i] - 'a'] += (m ? m + 1 : 1);
}
for (long long i = 0; i < (26); ++i) {
if (i) {
cout << ' ';
}
cout << cnt[i];
}
cout << "\n";
}
int32_t main() {
long long tt;
cin >> tt;
while (tt--) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int test;
scanf("%d", &test);
while (test--) {
int m, n;
string s;
scanf("%d%d", &m, &n);
cin >> s;
vector<int> data(26, 0);
vector<int> wrong(m, 0);
for (int i = 0; i < n; i++) {
int place;
scanf("%d", &place);
wrong[place - 1]++;
}
for (int i = m - 1; i > 0; i--) wrong[i - 1] += wrong[i];
for (int i = 0; i < m; i++) data[s[i] - 'a'] += wrong[i] + 1;
for (int i = 0; i < 26; i++) printf("%d ", data[i]);
puts("");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, m;
cin >> n >> m;
string str;
cin >> str;
vector<int> cnt('z' - 'a' + 1), r(n + 1);
for (int i = 0; i < m; i++) {
int p;
cin >> p;
r[p]--;
}
int cur = m + 1;
for (int i = 0; i < n; i++) {
cur += r[i];
cnt[str[i] - 'a'] += cur;
}
for (auto c : cnt) {
cout << c << ' ';
}
cout << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 100;
int vis[N];
long long cnt[30], temp[30];
char s[N];
int main() {
int w;
cin >> w;
while (w--) {
memset(vis, false, sizeof(vis));
memset(cnt, 0, sizeof(cnt));
memset(temp, 0, sizeof(temp));
int n, m;
scanf("%d%d%s", &n, &m, s + 1);
for (int i = 1; i <= m; i++) {
int pos;
scanf("%d", &pos);
vis[pos]++;
}
vis[n]++;
for (int i = 1; i <= n; i++) {
temp[s[i] - 'a']++;
if (!vis[i]) continue;
for (int j = 0; j < 26; j++) cnt[j] += temp[j] * vis[i];
}
for (int i = 0; i < 26; i++) printf("%lld ", cnt[i]);
printf("\n");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int T, n, m;
string s;
int vis[26];
int pos[maxn][26];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> T;
while (T--) {
memset(vis, 0, sizeof(vis));
cin >> n >> m;
for (int i = 0; i < 26; ++i) {
for (int j = 0; j <= n + 5; ++j) {
pos[j][i] = 0;
}
}
cin >> s;
for (int i = 0; i < s.size(); ++i) {
for (int j = 0; j < 26; ++j) {
pos[i][j] = pos[i - 1 == -1 ? 0 : i - 1][j];
}
pos[i][s[i] - 'a']++;
}
for (int i = 0, x; i < m; ++i) {
cin >> x;
x--;
for (int j = 0; j < 26; ++j) {
vis[j] += pos[x][j];
}
}
for (int j = 0; j < 26; ++j) {
vis[j] += pos[n - 1][j];
}
for (int i = 0; i < 26; ++i) {
cout << vis[i] << ' ';
}
cout << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin >> t;
while (t--) {
int a[26];
memset(a, 0, sizeof a);
int n, m;
cin >> n >> m;
int p[m + 1];
string s;
cin >> s;
for (int i = 0; i < m; i++) {
cin >> p[i];
p[i]--;
}
sort(p, p + m);
p[m] = n;
for (int i = 0, j = 0; i < n; i++) {
int x = s[i] - 97;
if (i <= p[j]) {
a[x] += m + 1 - j;
} else {
while (i > p[j]) j++;
a[x] += m + 1 - j;
}
}
for (int i = 0; i < 26; i++) cout << a[i] << " ";
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, m;
string s;
cin >> n >> m >> s;
vector<int> p(m);
vector<int> sum(n + 1);
for (int i = 0; i < m; i++) {
cin >> p[i];
sum[0]++;
sum[p[i]]--;
}
sum[0]++;
for (int i = 0; i < n; i++) {
sum[i + 1] += sum[i];
}
vector<long long> alpha(26);
for (int i = 0; i < n; i++) {
alpha[s[i] - 'a'] += sum[i];
}
for (int i = 0; i < 26; i++) {
cout << alpha[i] << ((i + 1 == 26) ? "\n" : " ");
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, m;
cin >> n >> m;
int ans[26];
memset(ans, 0, sizeof ans);
string s;
cin >> s;
for (auto x : s) ans[x - 'a']++;
int pre[n];
int x;
memset(pre, 0, sizeof pre);
for (int i = 0; i < m; i++) {
cin >> x;
pre[x - 1]++;
}
for (int i = n - 1; i; i--) pre[i - 1] += pre[i];
for (int i = 0; i < n; i++) ans[s[i] - 'a'] += pre[i];
for (auto i : ans) cout << i << " ";
cout << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
long long test, n, r, m, k, x, y, q, z, d, ans, a[N], b[N];
string s;
void solve() {
int n, m;
cin >> n >> m >> s;
for (long long i = 0; i <= 25; i++) b[i] = 0;
for (long long i = 0; i <= n + 1; i++) a[i] = 0;
for (long long i = 1; i <= m; i++) {
cin >> x;
a[x - 1]++;
}
for (long long i = n - 1, c = 0; i >= 0; i--) {
c += a[i];
b[s[i] - 'a'] += 1 + c;
}
for (int i = 0; i <= 25; i++) cout << b[i] << " ";
cout << "\n";
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> test;
while (test--) solve();
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, n, m, p, r;
string str;
vector<int> counts(26), reps;
cin >> t;
for (int i = 0; i < t; i++) {
cin >> n >> m;
fill(counts.begin(), counts.end(), 0);
reps.resize(n - 1);
fill(reps.begin(), reps.end(), 0);
cin >> str;
for (int j = 0; j < m; j++) {
cin >> p;
reps[p - 1]++;
}
r = 1;
counts[str[n - 1] - 'a']++;
for (int j = n - 2; j >= 0; j--) {
r += reps[j];
counts[str[j] - 'a'] += r;
}
for (auto &c : counts) cout << c << " ";
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void InOut(bool DoIt) {
if (DoIt == true) {
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
}
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
map<char, int> cnt;
int main() {
InOut(0);
int t;
cin >> t;
while (t-- > 0) {
cnt.clear();
int n, m;
cin >> n >> m;
vector<int> a(n, 0);
string s;
cin >> s;
int p;
a[0] = 1;
for (int i = 0; i < m; ++i) {
cin >> p;
a[0]++;
a[p]--;
}
for (int i = 1; i < n; ++i) {
a[i] += a[i - 1];
}
for (int i = 0; i < n; ++i) {
int key = s[i];
cnt[key] += a[i];
}
for (int i = int('a'); i <= int('z'); i++) {
char key = char(i);
cout << cnt[key];
cout << ' ';
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int pre[26][2 * 100000 + 5];
int cnt[26];
char temp;
int main() {
int k;
scanf("%d", &k);
while (k--) {
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; i++)
for (int j = 0; j < 26; j++) pre[j][i] = 0;
memset(cnt, 0, sizeof(cnt));
for (int i = 1; i <= n; i++) {
cin >> temp;
for (int j = 0; j < 26; j++) pre[j][i] += pre[j][i - 1];
pre[temp - 'a'][i]++;
}
for (int i = 1, z; i <= m; i++) {
cin >> z;
for (int j = 0; j < 26; j++) {
cnt[j] += pre[j][z];
}
}
for (int i = 0; i < 26; i++) cnt[i] += pre[i][n];
for (int i = 0; i < 26; i++) {
if (i == 25)
printf("%d\n", cnt[i]);
else
cout << cnt[i] << " ";
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
char s[200005];
long long c[30][200005];
long long ans[30];
int main() {
int t;
cin >> t;
for (register int time = 1; time <= t; ++time) {
for (int i = 0; i < 30; i++) ans[i] = 0;
int n, m;
scanf("%d%d", &n, &m);
getchar();
for (register int i = 1; i <= n; ++i) scanf("%c", &s[i]);
for (register int i = 1; i <= n; ++i) {
char C = s[i];
for (register int j = 0; j < 26; ++j) {
if (char('a' + j) == C)
c[j][i] = c[j][i - 1] + 1;
else
c[j][i] = c[j][i - 1];
}
}
for (register int i = 1; i <= m; ++i) {
int x;
scanf("%d", &x);
for (register int k = 0; k < 26; ++k) ans[k] += c[k][x];
}
for (register int k = 0; k < 26; ++k) ans[k] += c[k][n];
for (register int i = 0; i < 25; ++i) printf("%lld ", ans[i]);
printf("%lld\n", ans[25]);
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long t;
cin >> t;
while (t--) {
long long n, m;
cin >> n >> m;
string s;
cin >> s;
long long a[m];
for (long long i = 0; i < m; i++) cin >> a[i];
for (long long i = 0; i < m; i++) a[i]--;
sort(a, a + m);
long long b[26];
fill(b, b + 26, 0);
long long k = m;
for (long long i = 0; i < m; i++) {
if (i == 0) {
for (long long j = 0; j <= a[i]; j++) b[s[j] - 'a'] += k;
} else {
for (long long j = a[i - 1] + 1; j <= a[i]; j++) {
b[s[j] - 'a'] += k;
}
}
k--;
}
for (long long i = 0; i < n; i++) b[s[i] - 'a']++;
for (long long i = 0; i < 26; i++) cout << b[i] << " ";
cout << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int arr[N][26], ans[26];
bool vis[N];
char str[N];
queue<int> q;
int main() {
int tmp, n, m = 0;
scanf("%d", &tmp);
while (tmp--) {
for (int i = 1; i <= m; i++) {
memset(arr[i], 0, sizeof(arr[i]));
}
memset(ans, 0, sizeof(ans));
scanf("%d%d", &m, &n);
scanf("%s", str + 1);
for (int i = 0, f; i < n; i++) {
scanf("%d", &f);
vis[f] = true;
q.push(f);
}
for (int i = 1; i <= m; i++) {
int word = str[i] - 'a';
for (int j = 0; j < 26; j++) {
arr[i][j] = arr[i - 1][j];
if (word == j) {
arr[i][j]++;
}
}
ans[word]++;
}
while (q.size()) {
int f = q.front();
q.pop();
for (int i = 0; i < 26; i++) {
ans[i] += arr[f][i];
}
}
for (int i = 0; i < 26; i++) {
printf("%d%c", ans[i], (i == 25 ? '\n' : ' '));
;
}
}
return 0;
}
|
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std;
void IO() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
long long binary_exponention(long long a, long long b) {
if (b == 0) return 1;
long long res = binary_exponention(a, b / 2);
if (b % 2) return res * res * a % 998244353;
return res * res % 998244353;
}
inline void read(int a[], int n, int which = 0) {
if (which)
for (int i = 1; i <= n; i++) cin >> a[i];
else
for (int i = 0; i < n; i++) cin >> a[i];
}
inline void write(int a[], int n, int which = 0) {
if (which == 0)
for (int i = 0; i < n; i++) cout << a[i] << " ";
else
for (int i = 1; i <= n; i++) cout << a[i] << " ";
}
int dir8i[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dir8j[8] = {0, -1, -1, -1, 0, 1, 1, 1};
int dir4i[4] = {-1, 0, 1, 0};
int dir4j[4] = {0, -1, 0, 1};
void solve() {
int n, m;
cin >> n >> m;
vector<vector<int>> count(n, vector<int>(26, 0));
string s;
cin >> s;
int p[m];
for (int i = 0; i < m; i++) {
cin >> p[i];
p[i]--;
}
count[0][s[0] - 'a'] = 1;
for (int i = 1; i < int(s.size()); i++)
for (int j = 0; j < 26; j++)
if (j == s[i] - 'a')
count[i][j] = count[i - 1][j] + 1;
else
count[i][j] = count[i - 1][j];
long long counteach[26];
memset(counteach, 0, sizeof(counteach));
for (int i = 0; i < m; i++) {
for (int j = 0; j < 26; j++) {
counteach[j] += count[p[i]][j];
}
}
for (int i = 0; i < 26; i++) counteach[i] += count[n - 1][i];
for (int i : counteach) cout << i << " ";
cout << "\n";
}
int main() {
IO();
int t;
cin >> t;
while (t--) solve();
}
|
#include <bits/stdc++.h>
using namespace std;
char s[200005];
int f[200005];
int b[200005];
int main() {
ios::sync_with_stdio(false);
int t, n, m, p;
cin >> t;
while (t--) {
memset(f, 0, sizeof(f));
memset(b, 0, sizeof(b));
cin >> n >> m;
cin >> s + 1;
for (int i = 1; i <= m; i++) {
cin >> p;
f[p]++;
}
for (int i = n - 1; i >= 1; i--) f[i] += f[i + 1];
for (int i = 1; i <= n; i++) b[s[i] - 'a' + 1] += f[i] + 1;
for (int i = 1; i <= 26; i++) cout << b[i] << " ";
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
char a[N];
int b[N];
int c[N];
int ans[30];
void solve() {
int n, m;
scanf("%d %d", &n, &m);
memset(ans, 0, sizeof(ans));
scanf("%s", a + 1);
for (int i = 1; i <= m; i++) {
scanf("%d", &b[i]);
c[b[i]]++;
}
int now = 1;
for (int i = n; i >= 1; i--) {
now += c[i];
ans[a[i] - 'a'] += now;
}
for (int i = 1; i <= m; i++) c[b[i]]--;
for (int i = 0; i <= 25; i++) printf("%d ", ans[i]);
puts("");
}
int main() {
int _;
scanf("%d", &_);
while (_--) solve();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long sz = 3e5 + 5;
char s[sz];
int d[30][sz], a[sz];
int main() {
int t;
cin >> t;
while (t--) {
int n, m;
scanf("%d %d", &n, &m);
scanf("%s", s);
for (int i = 0; i < m; i++) scanf("%d", &a[i]);
for (int i = 0; i < n; i++) {
d[s[i] - 'a'][i] = 1;
for (int j = 0; j < 30; j++) {
if (i) d[j][i] += d[j][i - 1];
}
}
int ans[30] = {0};
a[m] = n;
for (int i = 0; i <= m; i++) {
for (int j = 0; j < 30; j++) {
ans[j] += d[j][a[i] - 1];
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < 30; j++) {
d[j][i] = 0;
}
}
for (int i = 0; i < 26; i++) printf("%d ", ans[i]);
puts("");
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long a, b, c[200005], d[200005], e, f, mx, mn = 1e9, ct = 0, sum, n, t,
mn2, ct2, h[26], dif, ans;
string s, p, m;
char ch[26];
bool kk, k;
int main() {
cin >> t;
while (t--) {
map<char, int> mp;
for (int i = 0; i < 200005; i++) c[i] = 0;
cin >> a >> b >> s;
for (int i = 0; i < b; i++) {
cin >> d[i];
c[d[i]]--;
}
c[0] = b;
for (int i = 1; i < a; i++) {
c[i] = c[i - 1] + c[i];
}
for (int i = 0; i < a; i++) {
c[i]++;
}
for (int i = 0; i < a; i++) {
mp[s[i]] += c[i];
}
for (int i = 0; i < 26; i++) {
char ch = 'a' + i;
cout << mp[ch] << " ";
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
using std::string;
void __Check(bool condition, const char* expression, int line) {
if (!condition) {
fprintf(stderr, "Check failed at line %d: %s\n", line, expression);
exit(-1);
}
}
template <class Collection, class Key>
bool ContainsKey(const Collection& collection, const Key& key) {
return collection.find(key) != collection.end();
}
const int INF = 0x3F3F3F3F;
const int INIT = -1;
int n, m;
string s;
const int MAX = 2 * 1e5 + 7;
int pre[MAX][26];
int ans[26];
int main() {
int tc;
cin >> tc;
while (tc--) {
cin >> n >> m;
cin >> s;
std::memset(ans, 0, sizeof(ans));
for (int j = 0; j < 26; j++) {
pre[0][j] = 0;
}
for (int i = 1; i <= n; i++) {
for (int j = 0; j < 26; j++) {
pre[i][j] = pre[i - 1][j];
}
uint8_t c = s[i - 1] - 'a';
pre[i][c]++;
}
for (int i = 0; i < m; i++) {
int p;
cin >> p;
for (int j = 0; j < 26; j++) {
ans[j] += pre[p][j];
}
}
for (int j = 0; j < 26; j++) {
printf("%d ", ans[j] + pre[n][j]);
}
printf("\n");
}
}
|
#include <bits/stdc++.h>
const int N = 2e5 + 9;
int t, n, m, p[N], x;
char c[N];
int s[30];
using namespace std;
int main() {
scanf("%d", &t);
while (t--) {
memset(s, 0, sizeof s);
memset(p, 0, sizeof p);
scanf("%d %d\n", &n, &m);
for (int i = 0; i < n; i++) scanf("%c", &c[i]);
for (int i = 0; i < m; i++) {
scanf("%d", &x);
++p[x - 1];
}
for (int i = n - 2; i >= 0; --i) p[i] += p[i + 1];
for (int i = 0; i < n; i++) ++s[c[i] - 'a'];
for (int i = 0; i < n; i++) s[c[i] - 'a'] += p[i];
for (int i = 0; i < 26; i++) printf("%d ", s[i]);
puts("");
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long long n, m;
cin >> n >> m;
string s;
cin >> s;
long long k[m];
for (long long i = 0; i < m; i++) cin >> k[i];
long long a[n + 1];
for (long long i = 1; i <= n; i++) {
a[i] = s.at(i - 1) - 'a';
}
long long g[n + 1][26];
for (long long i = 0; i <= n; i++) {
for (long long j = 0; j < 26; j++) {
g[i][j] = 0;
}
}
for (long long i = 1; i <= n; i++) {
for (long long j = 0; j < 26; j++) {
if (j == a[i])
g[i][j] = g[i - 1][j] + 1;
else
g[i][j] = g[i - 1][j];
}
}
long long ans[26] = {0};
for (long long i = 0; i < m; i++) {
for (long long i1 = 0; i1 < 26; i1++) {
ans[i1] += g[k[i]][i1];
}
}
for (long long i = 0; i < 26; i++) ans[i] += g[n][i];
for (long long i = 0; i < 26; i++) cout << ans[i] << " ";
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long INF = 2000000000000000000LL;
const int inf = 0x3f3f3f3f;
const long double EPS = 1e-9;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
;
int t;
cin >> t;
while (t--) {
map<char, int> M;
for (int i = 0; i < 26; i++) M['a' + i] = i;
int n, m;
string s;
cin >> n >> m >> s;
vector<int> v;
long long ans[30] = {0};
for (int i = 0; i < m; i++) {
int x;
cin >> x;
v.push_back(x);
}
v.push_back(2e5);
sort((v).begin(), (v).end());
int cnt = 1, pos = 0, j = 0, p = 0;
for (int i = 0; i < m; i++) {
if (v[i] != v[i + 1]) {
for (j = pos; j < v[i]; j++) {
ans[M[s[j]]] += m - p + 1;
}
pos = v[i];
p = i + 1;
}
}
for (j = pos; j < n; j++) {
ans[M[s[j]]] += 1;
}
for (int i = 0; i < 26; i++) {
cout << ans[i] << " ";
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
using namespace std;
vector<set<int>> pos;
int arr[200010][26];
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while (t--) {
int n, m;
cin >> n >> m;
string s;
cin >> s;
memset(arr, 0, sizeof(arr[0]) * (n + 5));
for (int i = 0; i < n; i++) {
for (int j = 0; j < 26; j++) arr[i + 1][j] += arr[i][j];
arr[i + 1][s[i] - 'a']++;
}
int u;
for (int i = 0; i < m; i++) {
cin >> u;
for (int j = 0; j < 26; j++) arr[n][j] += arr[u][j];
}
for (int i = 0; i < 26; i++) cout << arr[n][i] << " ";
cout << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
multiset<pair<int, int> > pool;
multiset<pair<int, int> >::iterator it;
struct node {
int first, second;
bool operator<(const node& b) const {
if (first == b.first) return second < b.second;
return first > b.first;
}
};
int letter[300000 + 5], flag[300000 + 5], point[300000 + 5], s[300000 + 5];
int re(char c) { return c - 'a' + 1; }
void solve() {
memset(letter, 0, sizeof(letter));
memset(flag, 0, sizeof(flag));
memset(point, 0, sizeof(point));
memset(s, 0, sizeof(s));
int n, m;
scanf("%d%d", &n, &m);
getchar();
for (int i = 0; i < n; i++) {
scanf("%c", &s[i]);
}
for (int i = 1; i <= m; i++) {
scanf("%d", &point[i]);
}
point[m + 1] = n;
sort(point, point + 1 + m + 1);
for (int i = 0; i <= m; i++) {
for (int j = point[i]; j < point[i + 1]; j++) {
flag[re(s[j])]++;
}
for (int i = 1; i <= 26; i++) {
letter[i] += flag[i];
}
}
for (int i = 1; i <= 26; i++) {
printf("%d ", letter[i]);
}
printf("\n");
}
signed main() {
int t = 1;
scanf("%d", &t);
while (t--) {
solve();
}
}
|
#include <bits/stdc++.h>
using namespace std;
void add(vector<int>& a, vector<int>& b) {
for (int i = 0; i < b.size(); i++) {
a[i] += b[i];
}
}
int main() {
int t;
cin >> t;
while (t--) {
int n, m;
cin >> n >> m;
string s;
cin >> s;
map<int, int> res;
for (int i = 0; i < m; i++) {
int v;
cin >> v;
res[v - 1]++;
}
vector<int> dc(26, 0);
vector<int> ans(26, 0);
for (int i = 0; i < n; i++) {
dc[s[i] - 'a']++;
while (res[i] >= 1) {
res[i]--;
add(ans, dc);
}
}
add(ans, dc);
for (int i = 0; i < 26; i++) cout << ans[i] << " ";
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, m;
cin >> n >> m;
string s;
cin >> s;
int a, b[27], p[s.size() + 1], k = 1;
for (int i = 0; i <= s.size(); i++) p[i] = 0;
for (int i = 0; i < 27; i++) b[i] = 0;
for (int i = 0; i < m; i++) {
cin >> a;
p[a - 1]++;
}
for (int i = s.size() - 1; i >= 0; i--) {
if (p[i]) k += p[i];
b[s[i] - 'a'] += k;
}
for (int i = 0; i < 26; i++) cout << b[i] << " ";
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main(void) {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while (t--) {
int n, m;
cin >> n >> m;
string s;
cin >> s;
vector<int> idx(m);
for (int i = 0; i < m; i++) cin >> idx[i];
vector<long long> ans(26, 0);
vector<vector<int>> pre(n);
for (int i = 0; i < n; i++) pre[i].resize(26, 0);
pre[0][s[0] - 'a']++;
for (int i = 1; i < n; i++) {
for (int j = 0; j < 26; j++) pre[i][j] = pre[i - 1][j];
pre[i][s[i] - 'a']++;
}
for (int i = 0; i < m; i++) {
for (int j = 0; j < 26; j++) {
ans[j] += (long long)(pre[idx[i] - 1][j]);
}
}
for (int i = 0; i < n; i++) ans[s[i] - 'a']++;
for (int i = 0; i < 26; i++) cout << ans[i] << " ";
cout << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
int n, m, p1, p2, ans[26], last[26], temp[26];
string s;
while (t--) {
memset(ans, 0, sizeof(ans));
memset(last, 0, sizeof(last));
memset(temp, 0, sizeof(temp));
cin >> n;
cin >> m;
cin >> s;
int x[m];
for (int i = 0; i < m; ++i) cin >> x[i];
sort(x, x + m);
for (int i = 0; i < x[0]; ++i) ++temp[s[i] - 'a'];
for (int j = 0; j < 26; ++j) {
ans[j] = temp[j];
}
for (int i = 1; i < m; ++i) {
for (int j = x[i - 1]; j < x[i]; ++j) {
++temp[s[j] - 'a'];
}
for (int j = 0; j < 26; ++j) {
ans[j] += temp[j];
}
}
for (int i = 0; i < n; ++i) ++ans[s[i] - 'a'];
for (int i = 0; i < 26; ++i) cout << ans[i] << " ";
cout << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long long n, m;
cin >> n >> m;
long long letter[26];
long long freq[n + 1];
string s;
cin >> s;
s = " " + s;
for (long long i = (0); i < (n + 1); i++) freq[i] = 0;
for (long long i = (0); i < (m); i++) {
long long tmp;
cin >> tmp;
freq[1]++;
freq[tmp + 1]--;
}
for (long long i = (1); i < (n + 1); i++) freq[i] += freq[i - 1];
for (long long i = (0); i < (26); i++) letter[i] = 0;
for (long long i = (1); i < (n + 1); i++) letter[s[i] - 'a'] += freq[i] + 1;
for (long long i = (0); i < (26); i++) cout << letter[i] << " ";
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int len, m;
cin >> len >> m;
string str;
cin >> str;
vector<int> arr(len, 0);
for (int i = 0; i < m; i++) {
int x;
cin >> x;
x--;
arr[x]++;
}
vector<int> freq(26, 0);
vector<long long> ans(26);
for (int i = 0; i < len; i++) {
freq[str[i] - 'a']++;
for (int j = 0; j < 26; j++) {
ans[j] = ans[j] + freq[j] * (long long)arr[i];
}
}
for (int i = 0; i < 26; ++i) {
cout << ans[i] + freq[i] << " ";
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.141592653589793;
const long long mod = 1e9 + 7;
int CASE = 1;
const int mxn = 1e5 + 1;
const long long infll = 1e18;
const int infi = 1e9;
bool prime(long long n) {
if (n <= 1) return false;
if (n == 2 or n == 3) return true;
if (n % 2 == 0 or n % 3 == 0) return false;
for (long long i = 5; i * i <= n; i += 6)
if (n % i == 0 || n % (i + 2) == 0) return false;
return true;
}
long long __gcd(long long a, long long b) { return !b ? a : __gcd(b, a % b); }
long long power(long long a, long long b, long long MOD) {
long long x = a, res = 1, p = b;
while (p > 0) {
if (p & 1) res *= x;
x *= x;
p >>= 1;
x %= MOD, res %= MOD;
}
return res;
}
void solve() {
vector<int> ans(26, 0);
int n, q;
cin >> n >> q;
string s;
cin >> s;
vector<int> cnt(26, 0);
map<int, int> mp;
for (long long i = 0; i < q; i++) {
int x;
cin >> x;
mp[x]++;
}
int i = 0;
for (auto x : mp) {
for (; i < x.first; i++) {
cnt[s[i] - 'a']++;
}
for (long long j = 0; j < 26; j++) ans[j] += cnt[j] * x.second;
}
for (char c : s) ans[c - 'a']++;
for (long long i = 0; i < 26; i++) cout << ans[i] << ' ';
cout << '\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int T;
cin >> T;
while (T--) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct node {
int num[30];
} a[200005];
int b[200005];
int ans[30];
int main(void) {
int t;
cin >> t;
while (t--) {
memset(ans, 0, sizeof ans);
for (int i = 1; i <= 200000; i++) {
for (int j = 0; i < 26; i++) a[i].num[j] = 0;
}
int n, m;
string s;
cin >> n >> m >> s;
for (int i = 1; i <= m; i++) cin >> b[i];
s = " " + s;
for (int i = 1; i <= n; i++) {
for (int j = 0; j < 26; j++) {
if (s[i] - 'a' == j)
a[i].num[j] = a[i - 1].num[j] + 1;
else
a[i].num[j] = a[i - 1].num[j];
}
ans[s[i] - 'a']++;
}
for (int i = 1; i <= m; i++) {
for (int j = 0; j < 26; j++) {
ans[j] += a[b[i]].num[j];
}
}
for (int i = 0; i < 26; i++) cout << ans[i] << " ";
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while (T--) {
int n, m;
string s;
cin >> n >> m >> s;
vector<vector<int> > sum;
sum.resize(n);
for (int i = 0; i < n; ++i) {
sum[i].resize(26);
}
for (int i = 0; i < n; ++i) {
if (i > 0) {
sum[i] = sum[i - 1];
}
++sum[i][s[i] - 'a'];
}
vector<long long> ans;
ans.resize(26);
for (int i = 0; i < m; ++i) {
int p;
cin >> p;
--p;
for (int j = 0; j < 26; ++j) {
ans[j] += sum[p][j];
}
}
for (int j = 0; j < 26; ++j) {
ans[j] += sum[n - 1][j];
}
for (int i = 0; i < 26; ++i) {
cout << ans[i] << ' ';
}
cout << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int ans[26];
int main() {
cout.sync_with_stdio(false);
cin.tie(0);
int t, n, m, aux;
cin >> t;
string s;
while (t--) {
cin >> n >> m >> s;
int mat[n + 1][26];
for (int i = 0; i < 26; i++) {
mat[0][i] = 0;
ans[i] = 0;
}
for (int i = 1; i <= n; i++) {
for (int j = 0; j < 26; j++) {
mat[i][j] = mat[i - 1][j];
}
int c = s[i - 1] - 'a';
mat[i][c]++;
}
for (int i = 0; i < m; i++) {
cin >> aux;
for (int j = 0; j < 26; j++) {
ans[j] += mat[aux][j];
}
}
for (int j = 0; j < 26; j++) {
ans[j] += mat[n][j];
}
for (auto i : ans) {
cout << i << " ";
}
cout << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
inline void solve() {
long long n, m;
cin >> n >> m;
string s;
cin >> s;
vector<long long> p(m, 0);
for (long long i = 0; i < m; ++i) {
cin >> p[i];
--p[i];
}
map<char, long long> cnt;
for (auto i : s) ++cnt[i];
sort(p.rbegin(), p.rend());
long long cnt1 = 0, j = 0;
for (long long i = s.size() - 2; i >= 0; --i) {
while (p[j] >= i && j < p.size()) {
++cnt1;
++j;
}
cnt[s[i]] += cnt1;
}
for (char i = 'a'; i <= 'z'; ++i) cout << cnt[i] << " ";
cout << "\n";
}
signed main() {
long long t;
cin >> t;
while (t--) solve();
}
|
#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3f3f3f3f;
const long long mod = 1000000009;
const long long maxn = 200005;
void std_quick_io() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
long long cot[maxn][26];
int main() {
std_quick_io();
int t;
cin >> t;
while (t--) {
int n, m;
cin >> n >> m;
for (int i = 0; i < 26; i++) {
for (int j = 0; j < n + 1; j++) {
cot[j][i] = 0;
}
}
string s;
cin >> s;
vector<long long> res(m);
for (int i = 0; i < m; i++) {
cin >> res[i];
res[i]--;
}
res.push_back(n - 1);
cot[0][s[0] - 'a'] = 1;
for (int i = 1; i < n; i++) {
for (int j = 0; j < 26; j++) {
if (s[i] - 'a' == j) {
cot[i][j] = cot[i - 1][j] + 1LL;
} else {
cot[i][j] = cot[i - 1][j];
}
}
}
vector<long long> ans(26, 0);
for (int i = 0; i < 26; i++) {
for (int j = 0; j <= m; j++) {
ans[i] += cot[res[j]][i];
}
}
for (int i = 0; i < 26; i++) {
if (i != 0) cout << " ";
cout << ans[i];
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int tc;
cin >> tc;
while (tc--) {
int n, m;
string s;
cin >> n >> m >> s;
vector<int> p(m);
for (int i = 0; i < m; i++) {
cin >> p[i];
}
vector<int> ans(30, 0);
vector<int> aux(n, 1);
sort(p.rbegin(), p.rend());
int add = 0;
int j = 0;
for (int i = n - 1; i >= 0; i--) {
while (i == p[j] - 1 && j < m) {
add++;
j++;
}
aux[i] += add;
ans[int(s[i]) - 97] += aux[i];
}
for (int i = 0; i < 26; i++) {
cout << ans[i] << " ";
}
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while (t--) {
int n, m;
cin >> n >> m;
string s;
cin >> s;
int ans[26] = {0};
map<int, int> mp;
vector<int> v(m);
for (int i = 0; i < m; i++) {
cin >> v[i];
mp[v[i]]++;
}
int c = 0;
for (int i = n - 1; i >= 0; i--) {
ans[s[i] - 'a'] += 1 + c;
if (mp[i + 1]) {
ans[s[i] - 'a'] += mp[i + 1];
c += mp[i + 1];
}
}
for (int i = 0; i < 26; i++) cout << ans[i] << " ";
cout << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
int main() {
std::ios_base::sync_with_stdio(0);
cin.tie(NULL);
;
int t, n, m;
string s;
cin >> t;
while (t--) {
cin >> n >> m >> s;
vector<long long int> freq(26), arr(m);
for (int i = 0; i < m; i++) cin >> arr[i], arr[i]--;
arr.push_back(n - 1), m++;
sort(arr.begin(), arr.end());
for (int i = 0, j = 0; i < m; i++) {
while (j < n && j <= arr[i]) {
freq[s[j++] - 'a'] += m - i;
}
}
for (auto i : freq) cout << i << ' ';
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
int dx[] = {0, 0, 1, -1, 2, 2, -2, -2, 1, -1, 1, -1};
int dy[] = {1, -1, 0, 0, 1, -1, 1, -1, 2, 2, -2, -2};
using namespace std;
class PAIR {
public:
long long int first;
long long int second;
long long int third;
};
vector<long long int> V, V2, V3;
long long int ar[200010][30];
long long int ans[30];
int main() {
long long int tcase = 1;
scanf("%lld", &tcase);
for (long long int test = 1; test <= tcase; test++) {
long long int n, m;
string s;
scanf("%lld %lld", &n, &m);
for (long long int i = 0; i < n; i++) {
for (long long int j = 0; j < 27; j++) {
ar[i][j] = 0;
ans[j] = 0;
}
}
cin >> s;
for (long long int i = 0; i < n; i++) {
ar[i][s[i] - 'a']++;
ans[s[i] - 'a']++;
}
for (long long int i = 1; i < n; i++) {
for (long long int j = 0; j < 26; j++) {
ar[i][j] += ar[i - 1][j];
}
}
for (long long int i = 0; i < m; i++) {
long long int a;
scanf("%lld", &a);
for (long long int j = 0; j < 26; j++) {
ans[j] += ar[a - 1][j];
}
}
for (long long int i = 0; i < 26; i++) {
printf("%lld ", ans[i]);
}
printf("\n");
;
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
struct node {
int cnt[26];
inline void clear() { memset(cnt, 0, sizeof(cnt)); }
inline void operator+=(const node &rhs) {
for (register int i = 0; i < 26; ++i) cnt[i] += rhs.cnt[i];
}
} a[N], ans;
char str[N];
inline void work() {
int n, m;
scanf("%d%d%s", &n, &m, str + 1);
for (register int i = 1; i <= n; ++i) {
a[i] = a[i - 1];
++a[i].cnt[str[i] - 'a'];
}
ans = a[n];
while (m--) {
int p;
scanf("%d", &p);
ans += a[p];
}
for (register int i = 0; i < 26; ++i) printf("%d ", ans.cnt[i]);
putchar('\n');
}
int main() {
int T;
scanf("%d", &T);
while (T--) work();
return 0;
}
|
#include <bits/stdc++.h>
long long int MOD = 1000000007;
using namespace std;
long long int power(long long int xui, long long int y, long long int p) {
long long int res = 1;
xui = xui % p;
while (y > 0) {
if (y & 1) res = (res * xui) % p;
y = y >> 1;
xui = (xui * xui) % p;
}
return res % MOD;
}
long long int modInv(long long int n) { return power(n, MOD - 2, MOD); }
void add(long long int arr[], long long int N, long long int lo,
long long int hi, long long int val) {
arr[lo] += val;
if (hi != N - 1) arr[hi + 1] -= val;
}
void updateArray(long long int arr[], long long int N) {
for (long long int i = 1; i < N; i++) arr[i] += arr[i - 1];
}
void printArr(long long int arr[], long long int N) { updateArray(arr, N); }
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long int t;
cin >> t;
while (t--) {
long long int n, m;
cin >> n >> m;
string s;
cin >> s;
long long int p[m];
for (long long int i = 0; i < m; ++i) cin >> p[i];
long long int ans[n];
for (long long int i = 0; i < n; ++i) ans[i] = 0;
for (long long int i = 0; i < m; ++i) {
add(ans, n, 0, p[i] - 1, 1);
}
add(ans, n, 0, n - 1, 1);
printArr(ans, n);
unordered_map<char, long long int> mp2;
for (long long int i = 0; i < n; ++i) {
mp2[s[i]] += ans[i];
}
for (long long int i = 0; i < 26; ++i) {
char c = (char)(97 + i);
if (mp2.find(c) == mp2.end()) {
cout << 0 << " ";
} else {
cout << mp2[c] << " ";
}
}
cout << '\n';
}
}
|
#include <bits/stdc++.h>
using namespace std;
char s[200005];
long long int p[200005];
long long int p1[200005][26];
long long int count1[26];
long long int count3[26];
int main() {
int t;
scanf("%d", &t);
while (t--) {
long long int size, op;
scanf("%lld%lld", &size, &op);
scanf("%s", s + 1);
memset(count1, 0, sizeof(count1));
memset(count3, 0, sizeof(count3));
for (int i = 1; i <= size; i++) {
count1[s[i] - 'a']++;
count3[s[i] - 'a']++;
for (int j = 0; j < 26; j++) {
p1[i][j] = count1[j];
}
}
for (int i = 1; i <= op; i++) {
scanf("%lld", &p[i]);
for (int j = 0; j <= 25; j++) {
count3[j] += p1[p[i]][j];
}
if (p[i] == size) {
break;
}
}
for (int i = 0; i <= 25; i++) {
printf("%lld ", count3[i]);
}
printf("\n");
}
}
|
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 10;
const long long INF = 1e18;
const long long inf = -1e18;
const long long MOD = 1e9 + 7;
long long q, n, m, p[N], us[N], used[N][29], b[N];
string a;
int main() {
cin >> q;
for (int i = 1; i <= q; i++) {
cin >> n >> m;
cin >> a;
for (int j = 1; j <= m; j++) cin >> p[j];
for (int j = 0; j < a.size(); j++) {
us[a[j]]++;
for (int z = 'a'; z <= 'z'; z++) {
used[j + 1][z] = us[z];
}
}
for (int j = 1; j <= m; j++) {
for (int z = 'a'; z <= 'z'; z++) {
b[z] += used[p[j]][z];
}
}
for (int z = 'a'; z <= 'z'; z++) b[z] += used[n][z];
for (int j = 'a'; j <= 'z'; j++) {
cout << b[j] << " ";
}
cout << endl;
for (int j = 'a'; j <= 'z'; j++) {
b[j] = 0;
us[j] = 0;
}
for (int j = 0; j < a.size(); j++) {
for (int z = 'a'; z <= 'z'; z++) {
used[j][z] = 0;
}
}
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.