이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int n, l, a[20010], dp[110][10010], pos[10010], b[110], c[110];
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
cin >> n >> l;
for (int i = 1; i <= n; i++){
cin >> a[i];
a[i+n] = a[i];
}
int q;
cin >> q;
for (int i = 1; i <= q; i++){
cin >> b[i];
c[i] = b[i];
}
sort(c+1, c+q+1);
for (int i = 1; i <= q; i++){
pos[c[i]] = i;
}
pos[n+1] = q+1;
for (int i = n; i >= 0; i--){
if (pos[i] == 0)
pos[i] = pos[i+1];
}
int cnt = 0;
for (int sz = 1; sz <= n; sz++){
int curans = 0;
if (l+sz > n)
break;
for (int i = 1; i < l; i++){
if (a[i] != a[i+sz])
++curans;
}
for (int i = 1; i <= n; i++){
if (i+l-1+sz > n)
break;
if (i != 1 && a[i-1] != a[i+sz-1])
--curans;
if (a[i+l-1] != a[i+l-1+sz])
++curans;
//cout << sz << ' ' << i << ' ' << curans << endl;
/*if (curans <= 28 && i == 1){
cout << "kek " << curans << ' ' << pos[curans] << ' ' << pos[28] << endl;
}*/
++dp[pos[curans]][i];
++dp[pos[curans]][i+sz];
}
}
/*cout << cnt;
return 0;*/
for (int i = 1; i <= q; i++){
for (int j = 1; j <= n; j++)
dp[i][j] += dp[i-1][j];
}
for (int i = 1; i <= q; i++){
for (int j = 1; j <= n-l+1; j++){
cout << dp[pos[b[i]]][j] << ' ';
}
cout << "\n";
}
}
컴파일 시 표준 에러 (stderr) 메시지
lot.cpp: In function 'int main()':
lot.cpp:32:9: warning: unused variable 'cnt' [-Wunused-variable]
int cnt = 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... |