# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
112954 | luciocf | Lottery (CEOI18_lot) | C++14 | 688 ms | 8568 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
const int maxn = 1e4+10;
const int maxq = 110;
typedef pair<int, int> pii;
int a[maxn];
int first[maxn];
int ans[maxn][maxq];
pii query[maxq];
int main(void)
{
int n, l;
scanf("%d %d", &n, &l);
for (int i = 1; i <= n; i++)
scanf("%d", &a[i]);
int q;
scanf("%d", &q);
for (int i = 1; i <= q; i++)
{
scanf("%d", &query[i].ff);
query[i].ss = i;
}
sort(query+1, query+q+1);
for (int i = 0; i <= l; i++)
{
first[i] = q+1;
for (int j = 1; j <= q; j++)
{
if (query[j].ff >= i)
{
first[i] = query[j].ss;
break;
}
}
}
for (int i = 1; i+l-1 <= n; i++)
{
int at = 0;
for (int j = 1; j <= l; j++)
if (a[i+j-1] != a[j])
at++;
if (i != 1)
{
ans[1][first[at]]++;
ans[i][first[at]]++;
}
for (int j = 2; j+l-1 <= n; j++)
{
int pos = i+j-1;
if (pos+l-1 > n) break;
if (a[j-1] != a[pos-1]) at--;
if (a[j+l-1] != a[pos+l-1]) at++;
if (j != pos)
{
ans[j][first[at]]++;
ans[pos][first[at]]++;
}
}
}
for (int i = 1; i <= q; i++)
for (int j = 1; j <= n; j++)
ans[j][query[i].ss] += ans[j][query[i-1].ss];
for (int i = 1; i <= q; i++)
{
for (int j = 1; j <= n-l+1; j++)
{
if (j == n-l+1) printf("%d\n", ans[j][i]);
else printf("%d ", ans[j][i]);
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |