Submission #74094774
Source Code Expand
#include <bits/stdc++.h>
using ull = unsigned long long int;
using ll = long long int;
using lll = __int128;
using namespace std;
const int mod = 1e9 + 7;
int d[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
inline string sread() {
string s;
char ch = getchar();
// 跳过空白字符
while (ch == ' ' || ch == '\n' || ch == '\r') ch = getchar();
// 读取非空白字符
while (ch != ' ' && ch != '\n' && ch != '\r' && ch != EOF) {
s += ch;
ch = getchar();
}
return s;
}
ll read(){
ll k = 0,f = 1;
char c = getchar();
while(c < '0' || c > '9')
{
if(c == '-')f = -1;
c = getchar();
}
while(c >= '0' && c <= '9')k = k * 10 + c - '0',c = getchar();
return k * f; // 别忘记标记的负数要乘进去
}
// 调用时用 n = in();
void print(ll x){
if(x < 0)putchar('-'),x = -x;
if(x < 10)putchar(x + '0');
else print(x / 10),putchar(x % 10 + '0');
}
// 直接调用 out(n) 就行了
ll ksm(ll base, ll e){
ll res = 1;
while(e){
if(e & 1){
res = res * base % mod;
}
base = base * base % mod;
e >>= 1;
}
return res;
}//ksm板子
vector<vector<ll>> matrix_mul (vector<vector<ll>>& a, vector<vector<ll>>& b) {
int l1 = a.size(), l2 = b[0].size();
vector<vector<ll>>res(l1, vector<ll>(l2, 0));
for(int i = 0; i < l1; i++){
for(int k = 0; k < a[0].size(); k++){
if(a[i][k]){
for(int j = 0; j < l2; j++){
res[i][j] = (res[i][j] + a[i][k] * b[k][j]);
}
}
}
}
return res;
}// 矩阵a * 矩阵b(矩阵乘法)
void Solve(){
int n = read(), l = read(), r = read();
string s;
cin >> s;
auto cal = [&](int len) -> ll{
vector<ll>cnt(26, 0);
ll ans = 0;
for(int i = 0; i < len; i++){
int cur = s[i] - 'a';
cnt[cur]++;
ans += cnt[cur];
}
for(int i = len; i < n; i++){
int cur = s[i] - 'a';
cnt[cur]++;
ans += cnt[cur];
cnt[s[i - len] - 'a']--;
}
return ans;
};
cout << cal(r) - cal(l - 1);
}
signed main(){
int T = 1;
while(T--){
Solve();
}
return 0;
}
Submission Info
Submission Time
2026-03-14 21:20:11+0900
Task
C - Comfortable Distance
User
wmxw
Language
C++23 (GCC 15.2.0)
Score
300
Code Size
2385 Byte
Status
AC
Exec Time
10 ms
Memory
4488 KiB
Compile Error
./Main.cpp: In function 'std::vector<std::vector<long long int> > matrix_mul(std::vector<std::vector<long long int> >&, std::vector<std::vector<long long int> >&)':
./Main.cpp:53:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
53 | for(int k = 0; k < a[0].size(); k++){
| ~~^~~~~~~~~~~~~
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
300 / 300
Status
Set Name
Test Cases
Sample
sample00.txt, sample01.txt, sample02.txt
All
sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt
Case Name
Status
Exec Time
Memory
sample00.txt
AC
1 ms
3584 KiB
sample01.txt
AC
1 ms
3468 KiB
sample02.txt
AC
1 ms
3524 KiB
testcase00.txt
AC
1 ms
3548 KiB
testcase01.txt
AC
1 ms
3468 KiB
testcase02.txt
AC
2 ms
3880 KiB
testcase03.txt
AC
6 ms
3920 KiB
testcase04.txt
AC
3 ms
3856 KiB
testcase05.txt
AC
4 ms
3936 KiB
testcase06.txt
AC
3 ms
3660 KiB
testcase07.txt
AC
7 ms
4424 KiB
testcase08.txt
AC
7 ms
4424 KiB
testcase09.txt
AC
7 ms
4432 KiB
testcase10.txt
AC
7 ms
4444 KiB
testcase11.txt
AC
7 ms
4384 KiB
testcase12.txt
AC
10 ms
4252 KiB
testcase13.txt
AC
9 ms
4440 KiB
testcase14.txt
AC
8 ms
4436 KiB
testcase15.txt
AC
8 ms
4424 KiB
testcase16.txt
AC
10 ms
4372 KiB
testcase17.txt
AC
9 ms
4368 KiB
testcase18.txt
AC
8 ms
4488 KiB
testcase19.txt
AC
10 ms
4264 KiB