# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
897836 |
2024-01-03T18:57:52 Z |
alexdd |
Lottery (CEOI18_lot) |
C++17 |
|
644 ms |
8240 KB |
#include<bits/stdc++.h>
using namespace std;
int n,lun,cntq;
int a[10005];
int cntd[10005];
vector<pair<int,int>> qrys;
int unde[105];
int rez[105][10005];
int ultima[10005];
void solve()
{
for(int i=0;i<=n;i++)
{
ultima[i]=cntq;
for(int j=cntq-1;j>=0;j--)
if(i <= qrys[j].first && (j==0 || i > qrys[j-1].first))
ultima[i] = j;
}
for(int dif=-n;dif<=n;dif++)
{
if(dif==0)
continue;
int idk=0;
for(int i=max(1,-dif+1);i<=min(n,n-dif);i++)
{
if(a[i]!=a[i+dif])
idk++;
cntd[i] = idk;
}
for(int i=max(1,-dif+1);i<=min(n-lun+1,n-dif-lun+1);i++)
{
rez[ultima[cntd[i+lun-1] - cntd[i-1]]][i]++;
}
}
for(int i=1;i<=n;i++)
for(int j=1;j<cntq;j++)
rez[j][i] += rez[j-1][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].first;
qrys[i].second = i;
}
sort(qrys.begin(),qrys.end());
for(int i=0;i<cntq;i++)
unde[qrys[i].second] = i;
solve();
for(int i=0;i<cntq;i++)
{
for(int j=1;j+lun-1<=n;j++)
cout<<rez[unde[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
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 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 |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 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 |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
11 ms |
2396 KB |
Output is correct |
14 |
Correct |
7 ms |
2396 KB |
Output is correct |
15 |
Correct |
6 ms |
2396 KB |
Output is correct |
16 |
Correct |
9 ms |
2652 KB |
Output is correct |
17 |
Correct |
8 ms |
2396 KB |
Output is correct |
18 |
Correct |
8 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
568 ms |
856 KB |
Output is correct |
2 |
Correct |
572 ms |
852 KB |
Output is correct |
3 |
Correct |
243 ms |
596 KB |
Output is correct |
4 |
Correct |
159 ms |
584 KB |
Output is correct |
5 |
Correct |
91 ms |
344 KB |
Output is correct |
6 |
Correct |
147 ms |
588 KB |
Output is correct |
7 |
Correct |
95 ms |
552 KB |
Output is correct |
8 |
Correct |
123 ms |
552 KB |
Output is correct |
9 |
Correct |
162 ms |
616 KB |
Output is correct |
10 |
Correct |
163 ms |
592 KB |
Output is correct |
11 |
Correct |
14 ms |
348 KB |
Output is correct |
12 |
Correct |
112 ms |
576 KB |
Output is correct |
13 |
Correct |
102 ms |
348 KB |
Output is correct |
14 |
Correct |
110 ms |
564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
568 ms |
856 KB |
Output is correct |
2 |
Correct |
572 ms |
852 KB |
Output is correct |
3 |
Correct |
243 ms |
596 KB |
Output is correct |
4 |
Correct |
159 ms |
584 KB |
Output is correct |
5 |
Correct |
91 ms |
344 KB |
Output is correct |
6 |
Correct |
147 ms |
588 KB |
Output is correct |
7 |
Correct |
95 ms |
552 KB |
Output is correct |
8 |
Correct |
123 ms |
552 KB |
Output is correct |
9 |
Correct |
162 ms |
616 KB |
Output is correct |
10 |
Correct |
163 ms |
592 KB |
Output is correct |
11 |
Correct |
14 ms |
348 KB |
Output is correct |
12 |
Correct |
112 ms |
576 KB |
Output is correct |
13 |
Correct |
102 ms |
348 KB |
Output is correct |
14 |
Correct |
110 ms |
564 KB |
Output is correct |
15 |
Correct |
235 ms |
580 KB |
Output is correct |
16 |
Correct |
143 ms |
592 KB |
Output is correct |
17 |
Correct |
185 ms |
616 KB |
Output is correct |
18 |
Correct |
162 ms |
608 KB |
Output is correct |
19 |
Correct |
162 ms |
620 KB |
Output is correct |
20 |
Correct |
167 ms |
856 KB |
Output is correct |
21 |
Correct |
160 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 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 |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
11 ms |
2396 KB |
Output is correct |
14 |
Correct |
7 ms |
2396 KB |
Output is correct |
15 |
Correct |
6 ms |
2396 KB |
Output is correct |
16 |
Correct |
9 ms |
2652 KB |
Output is correct |
17 |
Correct |
8 ms |
2396 KB |
Output is correct |
18 |
Correct |
8 ms |
2396 KB |
Output is correct |
19 |
Correct |
568 ms |
856 KB |
Output is correct |
20 |
Correct |
572 ms |
852 KB |
Output is correct |
21 |
Correct |
243 ms |
596 KB |
Output is correct |
22 |
Correct |
159 ms |
584 KB |
Output is correct |
23 |
Correct |
91 ms |
344 KB |
Output is correct |
24 |
Correct |
147 ms |
588 KB |
Output is correct |
25 |
Correct |
95 ms |
552 KB |
Output is correct |
26 |
Correct |
123 ms |
552 KB |
Output is correct |
27 |
Correct |
162 ms |
616 KB |
Output is correct |
28 |
Correct |
163 ms |
592 KB |
Output is correct |
29 |
Correct |
14 ms |
348 KB |
Output is correct |
30 |
Correct |
112 ms |
576 KB |
Output is correct |
31 |
Correct |
102 ms |
348 KB |
Output is correct |
32 |
Correct |
110 ms |
564 KB |
Output is correct |
33 |
Correct |
235 ms |
580 KB |
Output is correct |
34 |
Correct |
143 ms |
592 KB |
Output is correct |
35 |
Correct |
185 ms |
616 KB |
Output is correct |
36 |
Correct |
162 ms |
608 KB |
Output is correct |
37 |
Correct |
162 ms |
620 KB |
Output is correct |
38 |
Correct |
167 ms |
856 KB |
Output is correct |
39 |
Correct |
160 ms |
596 KB |
Output is correct |
40 |
Correct |
582 ms |
3592 KB |
Output is correct |
41 |
Correct |
54 ms |
2640 KB |
Output is correct |
42 |
Correct |
178 ms |
3476 KB |
Output is correct |
43 |
Correct |
168 ms |
3432 KB |
Output is correct |
44 |
Correct |
165 ms |
3132 KB |
Output is correct |
45 |
Correct |
644 ms |
8164 KB |
Output is correct |
46 |
Correct |
68 ms |
4692 KB |
Output is correct |
47 |
Correct |
223 ms |
8240 KB |
Output is correct |
48 |
Correct |
206 ms |
6476 KB |
Output is correct |
49 |
Correct |
209 ms |
7180 KB |
Output is correct |