이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2000;
int v[MAX_N], diff[MAX_N][MAX_N], good[MAX_N][MAX_N + 1];
int main() {
int n, k;
cin >> n >> k;
for ( int i = 0; i < n; i++ )
cin >> v[i];
for ( int i = 0; i < n; i++ ) {
for ( int j = i + 1; j < n; j++ ) {
if ( v[i] == v[j] )
continue;
int l = min( k, i + 1 );
for ( int o = 0; o < l; o++ )
diff[i - o][j - o]++;
}
}
for ( int i = 0; i < n; i++ ) {
for ( int j = i + 1; j < n; j++ ) {
good[i][diff[i][j]]++;
good[j][diff[i][j]]++;
}
}
for ( int i = 0; i < n; i++ ) {
for ( int j = 1; j <= n; j++ )
good[i][j] += good[i][j - 1];
}
int q;
cin >> q;
while ( q-- ) {
int m;
cin >> m;
for ( int i = 0; i <= n - k; i++ )
cout << good[i][m] - 1 << " ";
cout << "\n";
}
return 0;
}
# | 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... |