답안 #897830

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
897830 2024-01-03T18:36:18 Z alexdd Lottery (CEOI18_lot) C++17
80 / 100
3000 ms 4072 KB
#include<bits/stdc++.h>
using namespace std;
int n,lun,cntq;
int a[10005];
int cntd[10005];
vector<int> qrys;
int rez[105][10005];
void solve()
{
    for(int dif=-n;dif<=n;dif++)
    {
        if(dif==0)
            continue;
        for(int i=1;i<=n;i++)
        {
            cntd[i] = cntd[i-1];
            if(i+dif>0 && i+dif<=n && a[i]!=a[i+dif])
                cntd[i]++;
        }
        for(int i=max(1,-dif+1);i<=min(n-lun+1,n-dif-lun+1);i++)
        {
            int aux = 0;
            aux = cntd[i+lun-1] - cntd[i-1];
            for(int j=0;j<cntq;j++)
            {
                if(aux <= qrys[j])
                    rez[j][i]++;
            }
        }
    }
}
signed main()
{
    cin>>n>>lun;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    cin>>cntq;
    qrys.resize(cntq);
    for(int i=0;i<cntq;i++)
    {
        cin>>qrys[i];
    }
    solve();
    for(int i=0;i<cntq;i++)
    {
        for(int j=1;j+lun-1<=n;j++)
            cout<<rez[i][j]<<" ";
        cout<<"\n";
    }
    return 0;
}
/**

cntd[dif][poz] = numarul de mismatches a[x] != a[x+dif], unde x = 1..poz
cntc[dif][i] = cntd[dif][i+lun-1] - cntd[dif][i-1] = distanta de la intervalul i..i+lun-1 la i+dif..i+dif+lun-1 este

distanta de la intervalul i..i+lun-1 la i+dif..i+dif+lun-1 este:
cntd[dif][i+lun-1] - cntd[dif][i-1]

ne fixam dif
vedem cum influenteaza dif cele q queryuri

*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 3 ms 2492 KB Output is correct
9 Correct 2 ms 2396 KB Output is correct
10 Correct 3 ms 2396 KB Output is correct
11 Correct 3 ms 2396 KB Output is correct
12 Correct 3 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 3 ms 2492 KB Output is correct
9 Correct 2 ms 2396 KB Output is correct
10 Correct 3 ms 2396 KB Output is correct
11 Correct 3 ms 2396 KB Output is correct
12 Correct 3 ms 2396 KB Output is correct
13 Correct 44 ms 484 KB Output is correct
14 Correct 50 ms 2540 KB Output is correct
15 Correct 43 ms 2396 KB Output is correct
16 Correct 70 ms 2568 KB Output is correct
17 Correct 69 ms 2396 KB Output is correct
18 Correct 66 ms 2536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 924 ms 816 KB Output is correct
2 Correct 822 ms 552 KB Output is correct
3 Correct 565 ms 548 KB Output is correct
4 Correct 558 ms 600 KB Output is correct
5 Correct 479 ms 604 KB Output is correct
6 Correct 569 ms 604 KB Output is correct
7 Correct 455 ms 600 KB Output is correct
8 Correct 479 ms 852 KB Output is correct
9 Correct 569 ms 628 KB Output is correct
10 Correct 570 ms 624 KB Output is correct
11 Correct 45 ms 348 KB Output is correct
12 Correct 426 ms 580 KB Output is correct
13 Correct 494 ms 604 KB Output is correct
14 Correct 493 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 924 ms 816 KB Output is correct
2 Correct 822 ms 552 KB Output is correct
3 Correct 565 ms 548 KB Output is correct
4 Correct 558 ms 600 KB Output is correct
5 Correct 479 ms 604 KB Output is correct
6 Correct 569 ms 604 KB Output is correct
7 Correct 455 ms 600 KB Output is correct
8 Correct 479 ms 852 KB Output is correct
9 Correct 569 ms 628 KB Output is correct
10 Correct 570 ms 624 KB Output is correct
11 Correct 45 ms 348 KB Output is correct
12 Correct 426 ms 580 KB Output is correct
13 Correct 494 ms 604 KB Output is correct
14 Correct 493 ms 604 KB Output is correct
15 Correct 585 ms 596 KB Output is correct
16 Correct 548 ms 628 KB Output is correct
17 Correct 584 ms 636 KB Output is correct
18 Correct 566 ms 620 KB Output is correct
19 Correct 583 ms 640 KB Output is correct
20 Correct 589 ms 632 KB Output is correct
21 Correct 591 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 3 ms 2492 KB Output is correct
9 Correct 2 ms 2396 KB Output is correct
10 Correct 3 ms 2396 KB Output is correct
11 Correct 3 ms 2396 KB Output is correct
12 Correct 3 ms 2396 KB Output is correct
13 Correct 44 ms 484 KB Output is correct
14 Correct 50 ms 2540 KB Output is correct
15 Correct 43 ms 2396 KB Output is correct
16 Correct 70 ms 2568 KB Output is correct
17 Correct 69 ms 2396 KB Output is correct
18 Correct 66 ms 2536 KB Output is correct
19 Correct 924 ms 816 KB Output is correct
20 Correct 822 ms 552 KB Output is correct
21 Correct 565 ms 548 KB Output is correct
22 Correct 558 ms 600 KB Output is correct
23 Correct 479 ms 604 KB Output is correct
24 Correct 569 ms 604 KB Output is correct
25 Correct 455 ms 600 KB Output is correct
26 Correct 479 ms 852 KB Output is correct
27 Correct 569 ms 628 KB Output is correct
28 Correct 570 ms 624 KB Output is correct
29 Correct 45 ms 348 KB Output is correct
30 Correct 426 ms 580 KB Output is correct
31 Correct 494 ms 604 KB Output is correct
32 Correct 493 ms 604 KB Output is correct
33 Correct 585 ms 596 KB Output is correct
34 Correct 548 ms 628 KB Output is correct
35 Correct 584 ms 636 KB Output is correct
36 Correct 566 ms 620 KB Output is correct
37 Correct 583 ms 640 KB Output is correct
38 Correct 589 ms 632 KB Output is correct
39 Correct 591 ms 604 KB Output is correct
40 Correct 2479 ms 3492 KB Output is correct
41 Correct 494 ms 2904 KB Output is correct
42 Correct 1925 ms 3408 KB Output is correct
43 Correct 1875 ms 3084 KB Output is correct
44 Correct 1871 ms 3292 KB Output is correct
45 Execution timed out 3102 ms 4072 KB Time limit exceeded
46 Halted 0 ms 0 KB -