#include <iostream>
#include <queue>
#include <stack>
#include <cstdlib>
#include <vector>
#include <cstring>
#include <cmath>
#include <cassert>
#include <unordered_set>
#include <map>
#include <deque>
#include <unordered_map>
#include <fstream>
#include <set>
#include <algorithm>
#include <iomanip>
#define fin cin
#define fout cout
#define F first
#define S second
#define PB push_back
#define PF push_front
#define MP make_pair
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn = 2e3 + 10;
int n, l;
int a[maxn];
int k = -1;
int similar (int fi, int se) {
int ret = 0;
for (int x = 0; x < l; x++) {
if (k != -1 and ret == k + 1)
break;
ret += (a[fi + x] != a[se + x]);
}
return ret;
}
int d[maxn][maxn];
int ans[10005];
void solve () {
int q;
cin >> q >> k;
for (int i = 0; i < n - l + 1; i++) {
int cnt = 0;
for (int j = i + 1; j < n - l + 1; j++) {
if (similar (i, j) <= k) {
cnt ++;
ans[j] ++;
}
}
cout << cnt + ans[i] << " ";
}
}
int main () {
ios_base::sync_with_stdio(false);
cin >> n >> l;
for (int i = 0; i < n; i++)
cin >> a[i];
if (n > 2000) {
solve ();
return 0;
}
for (int i = 0; i < n - l + 1; i++) {
for (int j = i + 1; j < n - l + 1; j++) {
int x = similar (i, j);
d[i][x] ++;
d[j][x] ++;
}
}
for (int i = 0; i < n - l + 1; i++) {
for (int j = 0; j <= l; j++) {
d[i][j + 1] += d[i][j];
}
}
int q;
cin >> q;
for (int i = 0; i < q; i++) {
int m;
cin >> m;
for (int j = 0; j < n - l + 1; j++)
cout << d[j][m] << " ";
cout << endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
756 KB |
Output is correct |
3 |
Correct |
2 ms |
824 KB |
Output is correct |
4 |
Correct |
2 ms |
824 KB |
Output is correct |
5 |
Correct |
2 ms |
824 KB |
Output is correct |
6 |
Correct |
2 ms |
920 KB |
Output is correct |
7 |
Correct |
2 ms |
932 KB |
Output is correct |
8 |
Correct |
4 ms |
1216 KB |
Output is correct |
9 |
Correct |
4 ms |
1260 KB |
Output is correct |
10 |
Correct |
4 ms |
1932 KB |
Output is correct |
11 |
Correct |
4 ms |
1932 KB |
Output is correct |
12 |
Correct |
4 ms |
1932 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
756 KB |
Output is correct |
3 |
Correct |
2 ms |
824 KB |
Output is correct |
4 |
Correct |
2 ms |
824 KB |
Output is correct |
5 |
Correct |
2 ms |
824 KB |
Output is correct |
6 |
Correct |
2 ms |
920 KB |
Output is correct |
7 |
Correct |
2 ms |
932 KB |
Output is correct |
8 |
Correct |
4 ms |
1216 KB |
Output is correct |
9 |
Correct |
4 ms |
1260 KB |
Output is correct |
10 |
Correct |
4 ms |
1932 KB |
Output is correct |
11 |
Correct |
4 ms |
1932 KB |
Output is correct |
12 |
Correct |
4 ms |
1932 KB |
Output is correct |
13 |
Correct |
26 ms |
8732 KB |
Output is correct |
14 |
Correct |
604 ms |
9644 KB |
Output is correct |
15 |
Correct |
617 ms |
9644 KB |
Output is correct |
16 |
Correct |
396 ms |
9644 KB |
Output is correct |
17 |
Correct |
491 ms |
9644 KB |
Output is correct |
18 |
Correct |
485 ms |
9660 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
9660 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
9660 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
756 KB |
Output is correct |
3 |
Correct |
2 ms |
824 KB |
Output is correct |
4 |
Correct |
2 ms |
824 KB |
Output is correct |
5 |
Correct |
2 ms |
824 KB |
Output is correct |
6 |
Correct |
2 ms |
920 KB |
Output is correct |
7 |
Correct |
2 ms |
932 KB |
Output is correct |
8 |
Correct |
4 ms |
1216 KB |
Output is correct |
9 |
Correct |
4 ms |
1260 KB |
Output is correct |
10 |
Correct |
4 ms |
1932 KB |
Output is correct |
11 |
Correct |
4 ms |
1932 KB |
Output is correct |
12 |
Correct |
4 ms |
1932 KB |
Output is correct |
13 |
Correct |
26 ms |
8732 KB |
Output is correct |
14 |
Correct |
604 ms |
9644 KB |
Output is correct |
15 |
Correct |
617 ms |
9644 KB |
Output is correct |
16 |
Correct |
396 ms |
9644 KB |
Output is correct |
17 |
Correct |
491 ms |
9644 KB |
Output is correct |
18 |
Correct |
485 ms |
9660 KB |
Output is correct |
19 |
Incorrect |
2 ms |
9660 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |